Android 关于expandableListView childrenView 点击改变颜色

1.点击后改变颜色并保持颜色改变状态:

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

并在OnChildClickListener中添加

 view.setActivated(true);

 

2.点击时改变颜色,点击后恢复点击前的颜色

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@color/main_blue" android:state_pressed="false"/>
    <item android:drawable="@color/dark_blue" android:state_pressed="true"/>

</selector>

 

posted @ 2016-01-07 11:24  ShuaiWang  阅读(1012)  评论(0编辑  收藏  举报