A ViewStub is not designed to be recreated and put back in the view
hierarchy. What are you trying to achieve? If you are trying to add a
new view to the window every time the user presses a button, just use
ViewGroup.addView() and LayoutInflater.

On Sun, Aug 1, 2010 at 5:50 PM, kivy <[email protected]> wrote:
> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Romain Guy
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

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

Reply via email to