Transferred from: http://blog.csdn.net/shakespeare001/article/details/7788400/
1. Create a Mylist_view.xml file
2. Edit the Mylist_view.xml file according to your specific needs
3. Referencing the Mylist_view.xml file
<?xml version= "1.0" encoding= "Utf-8"?> <selector xmlns:android= "http://schemas.android.com/apk/res/ Android "> <!--default background picture-- <item android:drawable=" @drawable/pic1 "/> <!-- Background picture without focus-- <item android:state_window_focused= "false" android:drawable= "@drawable/pic1"/> <!--get focus in non-touch mode and click Background picture- <item android:state_focused= "true" android:state_pressed= "true" android:drawable= "@drawable/pic2"/> <!--touch mode when clicked background picture-- <item android:state_focused= "False" android:state_pressed= "true" android:drawable= "@drawable/pic3"/> <!--selected picture background-- <item android:state_selected= "true" android:drawable= "@drawable/pic4"/> <!-- Get focus when picture background-- <item android:state_focused= "true" android:drawable= "@drawable/pic5"/> </selector>
Specifically as the link above.
How to use selector in Android