I've researched many answers on SO and come up with the following code to show the keyboard when my Dialog pops up:
final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Title");
final EditText input = new EditText(this);
input.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean focused) {
alertDialog
.getWindow()
.setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
});
input.setFocusable(true);
input.requestFocus();
alertDialog.setView(input);
alertDialog.show();
The dialog Shows, but the keyboard doesn't pop up. This is all within an onTouch(...) method if that makes a difference.
My app is landscape mode only. I find that in portrait mode, it is showing. Why is this?
Any help is appreciated.