在蓝牙手柄与手机连接成功了后 进入APP中,你会发现App里面有很多你想通过蓝牙手柄选择的地方,选择不到、无法获得焦点;
在你的布局里面加入这个android:focusableInTouchMode="true"(任何时候强制获得焦点,就是说不管你是蓝牙手柄还是认为点击)或者android:focusable="true"(只有在蓝牙手柄的情况下会获得焦点,如果蓝牙手柄没有连接的话则不会干扰其他事件)
怎么加:比如你的这个TextView有一个点击事件,在使用蓝牙手柄的时候希望蓝牙手柄能够选中它(textview控件)<TextViewandroid:id="@+id/tx"android:onClick="aaa"android:layout_width="wrap_content" android:layout_height="wrap_content" />android:focusable="true"android:background="@drawable/select_video"//当Textview被虚拟选中的时候出现的样式,改变背景颜色或者出现边框。
select_video.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@color/new_hot_text2"></item> <item android:state_focused="true" android:drawable="@color/colorPrimaryDark"> </item> <!--<item android:drawable="@color/colorAccent" />--> </selector>