EditText clearFocus

来源:互联网 发布:cad怎么添加网络打印机 编辑:程序博客网 时间:2024/05/02 02:18

当editText 调用clearFocus 取消焦点时,framework会把焦点给传给此页面的第一个focusable的控件,如果这个editText是唯一的一个focusable的,那么clearFocus会首先给自己一个hasFocus为True的OnFocusChangeListener,然后在执行clearFocus原本该执行的hasFocus为False的OnFocusChangeListener。


解决办法:

再xml文件中添加一个  android:focusable="true" android:focusableInTouchMode="true"的空控件

    <View        android:layout_width="0dip"        android:layout_height="0dip"        android:focusable="true"        android:focusableInTouchMode="true" />


原创粉丝点击