重新充气时出现错误
我正在尝试在单击按钮时膨胀视图存根。第一次按下按钮时它工作正常,但是当我第二次按下按钮时应用程序崩溃了。
我正在使用以下代码
public void display(View V) //Button Click
{
stub=(ViewStub) findViewById(R.id.stub);
inflated=stub.inflate();
}
有人可以给我一些帮助吗?
I am trying to inflate view stub on Button click. It works fine when the button is pressed for the first time, but when I press the button a second time the application crashes.
I am Using the following code
public void display(View V) //Button Click
{
stub=(ViewStub) findViewById(R.id.stub);
inflated=stub.inflate();
}
Can anyone give me some help on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以添加以下检查以避免多次尝试膨胀 ViewStub :
迟到的回答,但也许会对某人有所帮助:)
You can add the following check to avoid trying to inflate the ViewStub several times:
Late answer, but maybe it will help someone :)