i've researched many answers on , come following code show keyboard when 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, keyboard doesn't pop up. within ontouch(...) method if makes difference.
my app landscape mode only. find in portrait mode, showing. why this?
any appreciated.
it looks landscape mode throwing me off. following piece of code solved problem immediately:
imm.togglesoftinput(inputmethodmanager.show_forced, inputmethodmanager.hide_implicit_only); imm.showsoftinput(input, inputmethodmanager.show_forced); alertdialog .getwindow() .setsoftinputmode( windowmanager.layoutparams.soft_input_state_always_visible);
Comments
Post a Comment