问题
I have a problem with spinner inside activity , that child of Activity group . when I clicked on spinner , that isn't expanded and "Force Close" window appears I was checked Logcat and catch "BadTokenException ", see below :
http://i227.photobucket.com/albums/dd299/lavender-90/stackflow.jpg
my XML:
<Spinner
android:id="@+id/aroundSP"
android:layout_height="wrap_content"
android:prompt="@string/touraround"
android:layout_width="fill_parent"
android:entries="@array/Triparound"
android:layout_marginTop="250dip"
android:layout_marginLeft="4dip"
style="@style/ContentTitle">
</Spinner>
Thanks everyone!
回答1:
this works fine.
View viewToLoad = LayoutInflater.from(this.getParent()).inflate(
R.layout.marketlist, null);
this.setContentView(viewToLoad);
回答2:
If you are using context anywhere then you have to pass getParent()
context because you are in a child of activity group.
来源:https://stackoverflow.com/questions/6049496/spinner-within-child-of-activitygroup-doesnt-work