Strangely, if you use the native Alertdialog, you can always pop the input box by Setview (New EditText ()) method;
And in our custom alertdialog, often encounter the problem of input method, here I divided into 2 cases:
I. In activity, the EditText in custom Alertdialog does not play the input method
method One: In the inheritance Alertdialog, the OnCreate () method, set the following:
Requestwindowfeature (WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
The reason for this is that by looking at Alertdialog's documentation, it defaults to this:
Requestwindowfeature (WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
The document says Alertdialog default task you do not need to interact with the input method, so set up a flag without edittext, and if you want to interact with the input method, set flag_not_focusable,
method Two: Inherit Dialog,dialog the default style is ugly, but you need to do 2 operations, which are done in the OnCreate method
First: Remove the black head:
Requestwindowfeature (window.feature_no_title);//Remove the black head
Second: Remove the black background:
GetWindow (). Setbackgrounddrawableresource (Android. r.color.transparent);//The only way to get rid of the black background
two. In fragment, the EditText in custom Alertdialog does not play the input method
In this case, the method in the activity is not possible.
I also tried to set the input method settings, such as:
GetWindow (). Setsoftinputmode (WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
Also in fragment and activity for the same setting, but also let Edittext.requestfocus (), but not all;
Also tried to click on the EditText, the use of Inputmethodmanager Force pop-up, still does not work;
I later added an empty EditText with Setview (new EditText ()) before the show () method call, because it was a custom alertdialog that had the layout we specified, so this empty
EditText is not displayed, this time will be able to pop up the dialog box, the specific reason is unclear, guess should still focus on the issue of Access,
EditText in the custom dialog box in Android cannot eject the IME solution