This may be a bug, but not if there is a way to attach the view to the
window manager.
I have a class extending AlertDialog. The dialog has a drop down menu
that allows user to choose item. When the orientation is changed with
the drop down menu displayed, I get the exception listed below. I set
up the drop down view/resources in onStart() of the Dialog, as shown:
protected void onStart() {
super.onStart();
mySpinner = (Spinner) findViewById(R.id.spinner);
mySpinnerAdapter = new ArrayAdapter<Tee>(context,
android.R.layout.simple_spinner_item, myList);
mySpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mySpinner.setAdapter(mySpinnerAdapter);
}
This error is occuring because, though this Dialog is managed by the
Activity (using onCreateDialog, onPrepareDialog, etc.), the View
generated by the SpinnerAdapter is not. I see there is a way to grab
individual items from the drop down view, but not get the view itself
(to attach it).
How can the SpinnerAdapter not cause problems on any orientation change?
E/AndroidRuntime( 5329): java.lang.IllegalArgumentException: View not
attached to window m
anager
E/AndroidRuntime( 5329): at
android.view.WindowManagerImpl.findViewLocked(WindowMan
agerImpl.java:355)
E/AndroidRuntime( 5329): at
android.view.WindowManagerImpl.removeView(WindowManager
Impl.java:200)
E/AndroidRuntime( 5329): at
android.view.Window$LocalWindowManager.removeView(Windo
w.java:417)
E/AndroidRuntime( 5329): at
android.app.Dialog.dismissDialog(Dialog.java:279)
E/AndroidRuntime( 5329): at android.app.Dialog.access$000(Dialog.java:72)
E/AndroidRuntime( 5329): at android.app.Dialog$1.run(Dialog.java:108)
E/AndroidRuntime( 5329): at android.app.Dialog.dismiss(Dialog.java:263)
E/AndroidRuntime( 5329): at
android.widget.Spinner.onDetachedFromWindow(Spinner.jav
a:86)
E/AndroidRuntime( 5329): at
android.view.View.dispatchDetachedFromWindow(View.java:
5584)
E/AndroidRuntime( 5329): at
android.view.ViewGroup.dispatchDetachedFromWindow(ViewG
roup.java:1074)
E/AndroidRuntime( 5329): at
android.view.ViewGroup.dispatchDetachedFromWindow(ViewG
Thanks
--
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