fiddler fiddler - 9 months ago 73
Android Question

Android TextField : set focus + soft input programmatically

In my view, I have a search EditText and I would like to trigger programmatically the behaviour of a click event on the field, i.e give focus to the text field AND display soft keyboard if necessary (if no hard keyboard available).

I tried

. The field actually gets focus but soft keyboard is not displayed.

I tried
. But that only calls the OnClickListener of the field.

Any idea ?


Good sir, try this:


Im not sure, but this might be required on some phones (some of the older devices):

final InputMethodManager inputMethodManager = (InputMethodManager) context
inputMethodManager.showSoftInput(edittext, InputMethodManager.SHOW_IMPLICIT);