Android:带有 EditTexts 的 ListView 会扰乱焦点和 IME
我有带有自定义项目的 ListActivity,其中每个项目都有自己的 TextEdit。 点击其中任何一个都会弹出 IME 键盘,并导致 ListView 调整大小。 因此,最近通过点击获得焦点的 EditText 失去了焦点。 需要第二次点击才能使其集中或确定。 仅当我在列表中移动了超过 1 个项目时才会发生这种情况。
有什么方法可以打开 IME 并只需轻轻一按即可将焦点集中在 EditText 上吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想要调整列表大小吗?您可以覆盖 ListView.onSizeChanged 并使用它,而不是将其“冒泡”到 super.onSizeChanged (假设您对错误源的假设是正确的)?
Do you want the list to be resized? Can you override the ListView.onSizeChanged and consume it instead of "bubbeling" it to super.onSizeChanged (assuming your assumption on the error source is correct)?
我通过将点击的 EditText 存储在变量中并请求在延迟后关注它来解决这个问题。这是一种 hack,但有时 Android 需要 hack。
I solved this by storing the tapped EditText in a variable and requesting focus on it after a delay. It's a hack, but sometimes Android requires hacks.