加载布局的时候,老是报threadid=1: thread exiting with uncaught exception (group=0x41634c50)
报错原因:
<Button
android:id="@+id/id_login_btn_vericode"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:layout_weight="1"
android:background="@drawable/selector_button_bg"
android:enabled="false"
android:text="@string/button_get_verify"
android:textColor="@drawable/selector_button_color"
android:textSize="@dimen/font_30" />
中的android:textColor="@drawable/selector_button_color" 写成了:
selector_button_color.xml 如下:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawble="@drawble/button_disable_color" android:state_enabled="false"/>
<item android:drawble="@drawble/button_normal_color" android:state_enabled="true" android:state_pressed="false"/>
<item android:drawble="@drawble/button_pressed_color" android:state_enabled="true" android:state_pressed="true"/>
</selector>
主要错误在红色标注地方,正确写法是:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/button_disable_color" android:state_enabled="false"/>
<item android:color="@color/button_normal_color" android:state_enabled="true" android:state_pressed="false"/>
<item android:color="@color/button_pressed_color" android:state_enabled="true" android:state_pressed="true"/>
</selector>
button_text_disable_color 、button_text_normal_color、button_text_pressed_color 在colors.xml里面定义
<color name="button_disable_color">#ffffffff</color>
<color name="button_normal_color">#88ffffff</color>
<color name="button_pressed_color">#ffffff</color>