The files you need to create in the Drawable folder, such as: My_select.xml, are as follows:
<?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_s Elected= "true"/> <item android:drawable= "@drawable/my_def"/></selector>
my_checked: Check
My_def: Not selected
Places to be aware of:
Android:state_selected= "true"
Must be state_selected property
The item layout file in the Layout folder: The item layout file is a sub-file in the adapter adapter
Add code to the control you need to select
android:background= "@drawable/course_select" android:descendantfocusability= "blocksdescendants"
Then reference the layout file in your adapter.
How to select the contents of an item without using the Notifydatasetchanged () method