</pre><p></p><p>在学习selector时遇到的问题</p><p>为Button添加Selector,如下</p><p></p><pre name="code" class="html"><?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/a1" android:state_focused="true"></item>
<item android:drawable="@drawable/a3" android:state_selected="true"></item>
<item android:drawable="@drawable/a2"></item>
</selector>
然后点击按钮总是无法响应,发现原来按钮控件必须满足以下两个属性才能响应获的焦点事件
android:focusable="true"
android:focusableInTouchMode="true"
</pre><pre name="code" class="html"><Button
android:id="@+id/b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg222"
android:focusable="true"
android:focusableInTouchMode="true" />