使用 windowSoftInputMode adjustmentPan 在 ListView 中编辑文本
我有一个 ListView
,每行都有一个 EditText
。我已在此活动的清单中将 windowSoftInputMode
设置为 adjustPan
,因此当我点击 EditText
时,布局会平移,以便在上方可见键盘。
当我第一次点击 EditText
时,这是有效的。但是,如果我点击后退按钮关闭键盘,然后再次点击相同的 EditText(不点击其他任何内容,因此光标保留在第一个 EditText
中),键盘会恢复,但布局不会这次不平移。其结果是 EditText
被键盘后面遮挡。
有没有人经历过这种行为/知道如何解决它?
谢谢
I have a ListView
with an EditText
in each row. I have set windowSoftInputMode
to adjustPan
in the manifest for this activity, so when I tap on an EditText
the layout pans so that it is visible above the keyboard.
This works the first time I tap on an EditText
. But if I hit the back button to dismiss the keyboard, then tap the same EditText again (without tapping anything else, so the cursor remains in the first EditText
), the keyboard comes back up but the layout does not pan this time. The result of this is that the EditText
is obscured behind the keyboard.
Has anyone experienced this behaviour / knows how to solve it?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仍然不确定为什么会发生这种情况,但我有一个解决方案。
我已经对
EditText
进行了子类化并重写了onKeyPreIme(int keyCode, KeyEvent event)
方法,如下所示:现在,当按下后退键时,
EditText
放弃焦点。然后再次点击它即可获得所需的行为。Still not sure why this happens, but I have a solution.
I have subclassed
EditText
and overridden the methodonKeyPreIme(int keyCode, KeyEvent event)
as follows:Now when the back key is pressed, the
EditText
gives up focus. Then tapping it again has the desired behaviour.