Saturday, July 31, 2010

[android-developers] How to solve this problem: Close Force Error when trying to populate viewStub

Hi there,

I just ran into a problem, while trying to populate a ViewStub by
tapping an ImageButton within a SlidingDrawer (the ViewStub should
also be part of the drawer), but all I get is a Force Close Error due
to a Null Pointer Exception. As I am using ViewStubs for the first
time I am not sure, what may have caused the exception. If someone
could help me out with this issue, this would be fantastic.

Thank you in advance.

This is the code I use to inflate the ViewStub:

btnExposure.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
importStub = ((ViewStub)
findViewById(R.id.stub_exposure)).inflate();

}
});
This is part of the Sliding Drawer xml file containing the ViewStub:

<ViewStub
android:id="@+id/stub_exposure"
android:inflatedId="@+id/exposureview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#77000000">
</ViewStub>
This is the exposureview.xml (the inflatedID):

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<SeekBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:thumb="@drawable/seek_thumb"
android:progress="50"
android:max="100">
</SeekBar>

</RelativeLayout>

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment