I am rendering an EditText
as one element of a list-style AlertDialog
(which is backed by the default ListView
implementation). I sort of expected that this circumstance would not change the behavior of EditText, but it does: a click on the EditText does not spawn the soft keyboard anymore.
After an hour of messing around with focus settings and click handlers I got fed up and debugged into 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 here is that mServedView
is the ListView that s backing the dialog, while view
is the EditText, and ListView.checkInputConnectionProxy()
does simply return false
in the default implementation of ListView (to be overridden by subclasses).
Worse, I couldn t find a way to set a custom ListView which allows proxying IME requests; AlertDialog.Builder.setView()
accepts a custom ListView, but this is not the ListView that InputMethodManager sees.
Any suggestions how to solve this?