I present EditText as one element of the AlertDialog list AlertDialog (which is supported by the default implementation of ListView ). I did not seem to expect this circumstance to change the behavior of EditText, but it does: clicking on EditText no longer spawns a soft keyboard.
After an hour of clutter with the focus settings and click handlers, I got tired and debugged in InputMethodManager.showSoftInput() , and found this:
public boolean showSoftInput(View view, int flags, ResultReceiver resultReceiver) { ... if (mServedView != view && (mServedView == null || !mServedView.checkInputConnectionProxy(view))) { return false; } ... } }
The problem is that mServedView is a ListView that supports dialogue, while view is EditText and ListView.checkInputConnectionProxy() makes it simply return false in the default implementation of ListView (must be overridden by subclasses).
Worse, I could not find a way to configure my own ListView, which allows you to proxy IME requests; AlertDialog.Builder.setView() accepts a custom ListView, but it is not a ListView that sees InputMethodManager.
Any suggestions how to solve this?
source share