5

I have ListActivity with custom items, where every item has it's own TextEdit. Taping on any of them brings IME keyboard up and it causes ListView to be resized. So EditText, which recently received focus by tap looses it. Second tap is required to put it focused or sure. It happens only when I have move than 1 items in the list.

Is there any way to open IME and keep focus on EditText by only one tap?

4

2 回答 2

0

我通过将点击的 EditText 存储在一个变量中并在延迟后请求关注它来解决这个问题。这是一个 hack,但有时 Android 需要 hack。

Handler handler = new Handler();
handler.postDelayed(new Runnable() {
    public void run() {
        EditText editText = getListAdapter().tappedEditText;
        if (editText != null) {
            editText.requestFocus();
        }
    }
}, 100);
于 2012-04-18T15:32:55.617 回答
0

你想调整列表的大小吗?您可以覆盖 ListView.onSizeChanged 并使用它而不是将其“冒泡”到 super.onSizeChanged (假设您对错误源的假设是正确的)?

于 2011-01-17T10:44:13.793 回答