I have a problem in my ListView. I want to change the background of selected item when I select it to a custom drawable that I have, but it doesn\'t work.
I want t
In touch mode there is no selected or focused state.
However, you can have a checked state (even without a checkbox) and use that to change properties upon "selection". In your java code where you set up to display your list add this line after you define the listview:
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
Then in your state list XML change this:
android:state_selected="true"
to this:
android:state_activated="true"
So now you should have:
And finally, set the background for your row view to point to your selector file:
You didn't give a name for your state list XML so I just used "item_selector". You should replace that with whatever the name of that file actually is.