android - 如何将注意力从 EditText 移开?

标签 android

在我的应用程序中,当 EditText 失去焦点时,我需要做一些事情。编辑 EditText 时,我不能让它失去焦点。在 Windows Phone 中有 this.Focus();方法,但在 android 中它似乎不一样。我该怎么办???

最佳答案

要远离编辑文本,应该使用 clearFocus();

如果您确实需要在焦点发生变化时处理任何特定事件,那么现在就来了..

**use Focus Change listener on view.**


onFocusChange(View v, boolean hasFocus)
  //Called when the focus state of a view has changed.
if(!hasfocus)
{
//Your piece of code if the focus is lost on text view..
}

关于android - 如何将注意力从 EditText 移开?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9792421/

相关文章:

android - 如何定位带和不带软导航键的设备(即 : Nexus 5, Galaxy S4)?

android - 菜鸟关于 "Hello World"Android教程的问题

java - 获取接收者的设备 token 以在 Firebase 中发送通知

Android:将图像对象转换为位图不起作用

android - 从服务启动 Activity 并等待结果

java - 如何用switch语句替换if else语句

java - 如何在每次滑动时显示各种布局

java - 无法在与 findViewById(R.id.textView) 同一行中使用 setText() 方法

Android Studio - 工具栏的抽屉切换不打开抽屉

java - 如何更改字符串样式