I\'m creating a custom dialog containing an EditText so that I can get text data from the user:
final EditText newKey = (EditText) findViewById(R.id.dialog_r
Also make sure you are not returning an already-shown dialog. For example, ProgressDialog
has a handy static method show() which takes some parameters and returns a ProgressDialog
. Turns out you can't use that method and return the resulting ProgressDialog
, because then when the OS tries to show it (and it's already shown), it will throw this same exception.
Beware, too: the above behavior is experienced on the Android emulator, but it actually did not throw an exception and worked just fine on my Droid Incredible running 2.2.
The exact way to solve this problem:
requestFeature(int)
is a method of Window
. You have to import this class (android.view.Window
).
And you have to get the Window of the AlertDialog.Builder object. Then call requestFeature(int)
. The input parameter is a constant of Window.
keyBuilder.getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
I had a similar problem. But my dialog was to be displayed for IME. When I switched to Dialog instead of AlertDialog, and omitted create, the program worked for me.