EditText 获得焦点后不会失去焦点
起初,应用程序加载屏幕后,我的 EditText 就获得了焦点,并且我禁用了该功能
android:focusable="true"
android:focusableInTouchMode="true"
,但是,单击 EditText 后无法失去焦点。当我尝试在文本区域之外单击时,焦点仍然存在。当我单击 EditText 更改值并按屏幕键盘上的“完成”时,也会发生这种情况。有谁知道我可以实现这个目标的方法吗?
At first my EditText had the focus as soon as the app loaded the screen and I disabled that with
android:focusable="true"
android:focusableInTouchMode="true"
However, there is no way to lose focus after clicking the EditText. The focus is still there when I try to click outside of the text area. This also happens when I click on the EditText to change the value and press "Done" on the on screen keyboard. Does anyone know a way for me to accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅当您单击其他可以获得焦点的内容时,焦点才会发生变化。问题是:如果你点击一个按钮,你可能不会失去焦点,除非你按照马修所说的去做。问题是: focusableInTouchMode 设置为“true”的按钮现在需要单击两次:一次用于获得焦点,一次用于执行 OnClick。一个棘手的问题,现在也困扰着我 。
Focus only changes if you click on something else that can gain focus. Issue is: If you click on a button for instance you might not lose focus, unless you do what Mathew said. Problem with that is: A button whose focusableInTouchMode is set to "true", needs now to be clicked TWICE: Once for gaining focus and once for performing OnClick. A nagging issue, that was haunting me as well right now.