I've got this dialog (I'm simplifying my use case):
class EditShoppingListDialog extends AlertDialog {
public EditShoppingListDialog(Context context) {
super(context/*, R.style.AppCustomDialog*/);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_addshoppinglist);
setTitle("Mike Testing");
}
}
I create and use this subclassed AlertDialog outside of the OnCreateDialog method (in the onContextItemSelected of my Activity) like this:
AlertDialog dialog = new EditShoppingListDialog(this);
dialog.show();
Now, I've been working with this code base for over a month now and never saw any problems, which lead me to wonder why they recommend using AlertDialog.Builder
for creating custom dialogs also.
When I deployed my app to a real device, I immediately started to see problems. The most blocking of them is that I cannot get the soft keyboard (IME?) to show up even when I click on an EditText field in the AlertDialog.
Here's the best part; If I say:
class EditShoppingListDialog extends Dialog {
...
}
The IME appears appears automatically if I click in an EditText in the dialog. I found this thread but the accepted solution does not work with AlertDialog.
However, I found doing this on the OnCreate of my derived AlertDialog helps show the IME, but it goes behind the dialog and I can't interact with it:
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,0);
I'm really sorry for the lost post, but I've spent more than 5 hours on this and would be very grateful for some help. The reason I insist on extending an AlertDialog is because I need a dialog without a title bar and it says in the Android Dialog documentation that I cannot have a Dialog without a title bar.