I have been designing an application which holds an expandable list. At the end of every list, an empty EditText
is ready to receive comments. I have the following
A solution is to post a delayed runnable that checks to see if the EditText view is still focused, and if it is not, focus it.
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(final View v, boolean hasFocus) {
if (hasFocus) {
// Request focus in a short time because the
// keyboard may steal it away.
v.postDelayed(new Runnable() {
@Override
public void run() {
if (!v.hasFocus()) {
v.requestFocus();
}
}
}, 200);
}
}
});