Android: ListView with EditTexts puts focus and IME

I have a ListActivity with custom elements, where each element has its own TextEdit. Touching any of them causes the keyboard to move the IME up, which causes the ListView to resize. So EditText, which recently got focus using a tap, loses it. A second click is needed for focus or confidence. This only happens when I have a move than 1 item in the list.

Is there a way to open IME and focus on EditText with just one click?

+5
source share
2 answers

Do you want the list to be changed? Can you override ListView.onSizeChanged and use it instead of bubbling it in super.onSizeChanged (assuming your assumption on the source of the error is correct)?

0
source

I solved this by storing the edited EditText in a variable and requesting focus on it after a delay. This is a hack, but sometimes Android requires a hack.

Handler handler = new Handler();
handler.postDelayed(new Runnable() {
    public void run() {
        EditText editText = getListAdapter().tappedEditText;
        if (editText != null) {
            editText.requestFocus();
        }
    }
}, 100);
0
source

All Articles