drawable文件夹中 须要建立的文件例如: my_select.xml,代码以下:java
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/my_checked" android:state_enabled="true" android:state_selected="true"/> <item android:drawable="@drawable/my_def"/> </selector>
my_checked: 选中效果图android
my_def: 未选中效果图布局
须要注意的地方: code
android:state_selected="true"
必定要是state_selected属性xml
layout文件夹中的Item布局文件中:Item布局文件是适配器Adapter中的子文件
utf-8
在你须要选中的控件中添加一下代码
it
android:background="@drawable/course_select" android:descendantFocusability="blocksDescendants"而后在你的适配器中引用该布局文件就行了