Hi there,

I am trying to recreate and reinflate a ViewStub each time an
ImageButton is pressed because at the moment my app crashes as soon as
I press the button a second time (due to a NullPointerException caused
by the ViewStub that doesn't exist anymore) but I am a little stuck as
I don't know how to recreate and reinvoke the ViewStub...

If someone could give me a hand here, that would be great.
Thanks in  advance.

This is what I have done so far:

 btnExposure = (ImageButton) findViewById(R.id.button_exposure);

      btnExposure.setOnClickListener(new OnClickListener()
        {

                @Override
                public void onClick(View v) {
                     if (findViewById(R.id.stub_exposure) != null){
                         ViewStub stub1 = (ViewStub)
findViewById(R.id.stub_exposure);
                         importStub = stub1.inflate();
                         toggle(importStub2);
                         }
                     else {
                         //DON'T KNOW WHAT I SHOULD DO HERE
                     }
                }


           }
        );

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to