Android: show soft keyboard automatically when focus is on an EditText

You can create a focus listener on the EditText on the AlertDialog, then get the AlertDialog‘s Window. From there you can make the soft keyboard show by calling setSoftInputMode. final AlertDialog dialog = …; 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); } } });

How to dismiss keyboard for UITextView with return key?

Figured I would post the snippet right here instead: Make sure you declare support for the UITextViewDelegate protocol. – (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { if([text isEqualToString:@”\n”]) { [textView resignFirstResponder]; return NO; } return YES; } Swift 4.0 update: func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { if text == … Read more

How can I dismiss the on screen keyboard?

For Flutter version 2 or latest : Since Flutter 2 with null safety this is the best way: FocusManager.instance.primaryFocus?.unfocus(); Note: using old ways leads to some problems like keep rebuild states; For Flutter version < 2 : As of Flutter v1.7.8+hotfix.2, the way to go is: FocusScope.of(context).unfocus(); Comment on PR about that: Now that #31909 … Read more

Android: How do I prevent the soft keyboard from pushing my view up?

You can simply switch your Activity’s windowSoftInputModeflag to adjustPan in your AndroidMainfest.xml file inside your activity tag. Check the official documentation for more info. <activity … android:windowSoftInputMode=”adjustPan”> </activity> If your container is not changing size, then you likely have the height set to “match parent”. If possible, set the parent to “Wrap Content”, or a … Read more

How to show soft-keyboard when edittext is focused

To force the soft keyboard to appear, you can use EditText yourEditText= (EditText) findViewById(R.id.yourEditText); yourEditText.requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT); And for removing the focus on EditText, sadly you need to have a dummy View to grab focus. To close it you can use InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0); This works … Read more