现在的位置: 首页 > 综合 > 正文

checkbox点击切换图片

2013年02月24日 ⁄ 综合 ⁄ 共 640字 ⁄ 字号 评论关闭

layout.xml

<CheckBox
        android:id="@+id/task_info_list_button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:focusable="false"
        style="@style/task_info_checkbox"
        android:layout_weight="1" 
         />

styles.xml

 <style name="task_info_checkbox">
		<item name="android:button">@drawable/task_type_image_selector</item>
	</style>

drawable下面建立task_type_image_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_checked="true" android:drawable="@drawable/btn_check_on" />
    <item android:state_checked="false" android:drawable="@drawable/btn_check_off_pressed" />
</selector>

抱歉!评论已关闭.