I did not find any logical method for this task. Can I do this by checking if the id on the viewStub has changed to the one listed as inflatedid ?
Javacode:
protected void plantViewTree() { // TODO Auto-generated method stub ViewStub mViewstub = (ViewStub) findViewById(R.id.viewStub00); if (mViewStub is inflated) { //do somthing }else mViewstub.inflate(); }
Update Comments on eOutput
According to this code, toast always displays its message, which means that since mViewStub assigned to findViewById , it is never null, except that viewStub is not available in the alyout subclass. Any suggestions.?
protected void plantViewTree() { // TODO Auto-generated method stub ViewStub mViewstub = (ViewStub) findViewById(R.id.viewStub00); if (mViewstub != null) Toast.makeText(getApplicationContext(), "view is inflated", Toast.LENGTH_LONG).show(); else mViewstub.inflate(); }
android view viewstub
LetsamrIt
source share