Android Listview No Longer Highlights Selection Onclick
I have a listview that was showing a yellowtint on items when I touched them. All I've done differently is change the background image in that listview xml , and now it no longer w
Solution 1:
When you added a new background to the ListView you overrode androids default background that was most likely using a selector to tint the ListItems depending on their state.
Try to use a custom selector
Create an XML file, mycustombackground.xml, and add this to it:
<?xml version="1.0" encoding="utf-8"?><selectorxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:state_pressed="true"android:drawable="@drawable/item_pressed" /><itemandroid:state_focused="true"android:drawable="@drawable/item_focused" /><itemandroid:drawable="@drawable/item_normal" /></selector>
Replace the @drawables with your own in relation to the state. Then set the background of your listview to the xml file.
android:background="@drawable/mycustombackground"
You may want to take a look into the XML to create the yellow color, or just create your own image.
Post a Comment for "Android Listview No Longer Highlights Selection Onclick"