A create XML file, Location: Drawable/xxx.xml, in the same directory remember to put related pictures
<?XML version= "1.0" encoding= "Utf-8"?> <selectorxmlns:android= "Http://schemas.android.com/apk/res/android"> <!--background picture by default - <Itemandroid:drawable= "@drawable/pic1" /> <!--background picture When there is no focus - <Itemandroid:state_window_focused= "false"android:drawable= "@drawable/pic1" /> <!--background picture When you get focus in non-touch mode and click - <Itemandroid:state_focused= "true"android:state_pressed= "true"android:drawable= "@drawable/pic2" /> <!--background picture when clicked in touch mode - <Itemandroid:state_focused= "false"android:state_pressed= "true"android:drawable= "@drawable/pic3" /> <!--picture Background When selected - <Itemandroid:state_selected= "true"android:drawable= "@drawable/pic4" /> <!--picture background when getting focus - <Itemandroid:state_focused= "true"android:drawable= "@drawable/pic5" /> </selector>
Two, using an XML file
Selector----Android Background selector