Android listview no longer highlights selection onclick

后端 未结 1 1576
再見小時候
再見小時候 2021-02-05 22:49

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 long

1条回答
  •  庸人自扰
    2021-02-05 23:08

    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:

    
     
        
        
        
     
    

    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.

    0 讨论(0)
提交回复
热议问题