I'm trying to learn how to use a Dialog, but I seem to be missing something.
(probably obvious to those who've used them before...)
Whenever I click on my Menu Item that opens the dialog, I get this:
01-01 08:00:16.214: ERROR/ACRA(259): fatal error : Unable to add window --
token null is not for an application
01-01 08:00:16.214: ERROR/ACRA(259):
android.view.WindowManager$BadTokenException: Unable to add window -- token
null is not for an application
01-01 08:00:16.214: ERROR/ACRA(259): at
android.view.ViewRoot.setView(ViewRoot.java:472)
01-01 08:00:16.214: ERROR/ACRA(259): at
android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
01-01 08:00:16.214: ERROR/ACRA(259): at
android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
01-01 08:00:16.214: ERROR/ACRA(259): at
android.app.Dialog.show(Dialog.java:239)
....
My activity has an onCreateDialog() method, which does get called and
returns successfully.
protected Dialog onCreateDialog( int id) {
// We only have one dialog, so we can ignore id...
Dialog dialog = new AboutBox(getApplicationContext());
dialog.setOnDismissListener(new DialogInterface.OnDismissListener()
{
public void onDismiss( DialogInterface dialog) {
removeDialog(1);
}
});
return dialog;
}
My custom dialog class is pretty trivial...
public class AboutBox extends Dialog {
public AboutBox( Context context) {
super(context);
}
protected void onCreate( Bundle savedInstanceState) {
setContentView(R.layout.about);
setTitle( "Testing");
Button btn = (Button) findViewById(R.id.AboutClose);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick( View v) {
dismiss();
}
});
}
}
As is it's layout:
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/AboutBox">
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:text="Just testing things"
android:gravity="center"
android:id="@+id/AboutTxt" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/AboutTxt"
android:layout_alignParentBottom="true"
android:text="Close"
android:gravity="center"
android:id="@+id/AboutClose" />
</RelativeLayout>
--
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