Android:强制 EditText 移除焦点? [英] Android: Force EditText to remove focus?

查看:37
本文介绍了Android:强制 EditText 移除焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够从 EditText 中移除焦点.例如,如果键盘出现,而用户使用后退按钮将其隐藏,我希望焦点和光标消失.怎么办?

I would like to be able to remove the focus from the EditText. For example if the Keyboard appears, and the user hides it with the back button, I would like the focus and the cursor to disappear. How can it be done?

推荐答案

您可以将其添加到 onCreate 中,它会在每次 Activity 启动时隐藏键盘.

You can add this to onCreate and it will hide the keyboard every time the Activity starts.

您还可以通过编程将焦点更改为另一个项目.

You can also programmatically change the focus to another item.

 this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

这篇关于Android:强制 EditText 移除焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆