when using AlertDialog.Builder with EditText, the Soft Keyboard doesn't pop
when using AlertDialog.Builder with EditText, the Soft Keyboard doesn't pop
I am using AlertDialog.Builder in order to create an input box, with EditText as the input method.
Unfortunately, the Soft Keyboard doesn't pop, although the EditText is in focus, unless you explicitly touch it again.
Is there a way to force it to pop?
I've tried the following, after the (AlertDialog.Builder).show(); but for no avail.
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mgr.showSoftInput(input, InputMethodManager.SHOW_FORCED);
Anyone can help?
Thanks!!
Answer by dhaag23 for when using AlertDialog.Builder with EditText, the Soft Keyboard doesn't pop
This was answered here already. Using an OnFocusChangeListener worked for me.
Answer by user590912 for when using AlertDialog.Builder with EditText, the Soft Keyboard doesn't pop
When you call showDialog to show a Dialogue created using AlertDialog in onCreateDialog
You should put the code here
@Override protected void onPrepareDialog (int id, Dialog dialog, Bundle args) { TextView editText=(TextView) dialog.findViewById(R....); editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); }
Answer by grine4ka for when using AlertDialog.Builder with EditText, the Soft Keyboard doesn't pop
I've made such a thing
AlertDialog.Builder b = new AlertDialog.Builder(this);//.... AlertDialog dialog = b.create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); dialog.show();
Answer by sulai for when using AlertDialog.Builder with EditText, the Soft Keyboard doesn't pop
A much better solution is given here.
dialog.getWindow().clearFlags( WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
No workaround. EditText
behaves as expected.
Answer by Alexander Fragotsis for when using AlertDialog.Builder with EditText, the Soft Keyboard doesn't pop
I've managed to solve it like this:
Dialog = builder.create(); Dialog.show(); Dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); Dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
Answer by Phuah Yee Keat for when using AlertDialog.Builder with EditText, the Soft Keyboard doesn't pop
I found out that the same code works properly on Tablet, the keyboard does pop up, but on Phone it doesn't, so researching further, seems to point to the "adjust" option.
I am using this, feels much cleaner.
AlertDialog d = builder.create(); d.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); d.show();
Answer by Yogesh Rathi for when using AlertDialog.Builder with EditText, the Soft Keyboard doesn't pop
Try this, its working for me
InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
And if you want to hide soft keyboard you can do this:
InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
Answer by Mohammed Shoeb for when using AlertDialog.Builder with EditText, the Soft Keyboard doesn't pop
Window window = dialog.getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72
0 comments:
Post a Comment