android xml 焦点,Edittext在xml文件中设置android:focusable=“false”之后,edittext再次获得焦点。...

在xml文件中,edittext这个控件设置了,android:focusable=“false”,

在代码中edittext.setfocusable(true),edittext这个控件仍然无法点击,百度之后,得到的结果是:

一定要按一下这个顺序写,重新使edittext获取焦点:

edittext.setFocusable(true);

edittext.setFocusableInTouchMode(true);

edittext.requestFocus();

edittext.requestFocusFromTouch();

这是为什么呢?

查阅API:

setFocusable(boolean):

Set whether this view can receive the focus. Setting this to false will also ensure that this view is not focusable in touch mode.

//--设置edittext是否可以获得焦点

setFocusableInTouchMode(boolean):

Set whether this view can receive focus while in touch mode. Setting this to true will also ensure that this view is focusable.

//--设置edittext在touch模式下是否可以获得焦点

requestFocus():

Call this to try to give focus to a specific view or to one of its


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部