How to remove focus from single editText
Possible Duplicate:
Stop EditText from gaining focus at Activity startup?
In my application I have a single EditText together with some TextViews, button and a spinner. My EditText receives focus since it is the only focusable view in this activity, I believe. My EditText shows with an orange border and cursor on the field.
Now I would like to remove the focus from this field (I don't want the cursor and border to show). Is there a way to do this?
I have been able to focus on the button by doing button.seFocusableInTouchMode() and button.requestFocus(). But this highlights the button and is obviously not what I want.
检查这个问题和选定的答案:停止EditText从活动启动获得焦点这是丑陋的,但它的工作原理,据我所知没有更好的解决方案。
你有没有尝试使用旧的View.clearFocus()
new to android.. tried
getWindow().getDecorView().clearFocus();
it works for me.. kindly correct me if there is something wrong :)
just to add .. you layout should have:
android:focusable="true"
android:focusableInTouchMode="true"
链接地址: http://www.djcxy.com/p/4136.html
上一篇: editText不会失去焦点
下一篇: 如何从单个editText中删除焦点