Getting error for while reinflating
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 th开发者_如何学Ce 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?
You can add the following check to avoid trying to inflate the ViewStub several times:
if(stub.getParent() != null) {
inflated = stub.inflate();
}
Late answer, but maybe it will help someone :)
精彩评论