目的是为了清除TextView的焦点,单纯clearFocus的话是没有效果的,首先在TextView的父布局上设置 :
android:focusable="true"
android:focusableInTouchMode="true"
<RelativeLayout
android:id="@+id/relativelayout_contact_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/contact_wireless_item_layout_margin_top"
android:focusable="true"
android:focusableInTouchMode="true">
<TextView
android:id="@+id/contact_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="@dimen/contact_wireless_item_name_margin_start"
android:layout_toStartOf="@id/linearlayout_menu"
an

当在Android代码中调用TextView的clearFocus方法无效时,可以尝试将TextView的父布局设置为focusable和focusableInTouchMode均为true,接着在代码中通过父布局的requestFocus来实现焦点清除。
最低0.47元/天 解锁文章
2507

被折叠的 条评论
为什么被折叠?



