Android ListView State List not showing default item background

前端 未结 3 972
忘掉有多难
忘掉有多难 2020-12-15 08:54

Have read over a number of related questions here at SO, as well as looked through the Android docs and source to try to figure this out, but I am stumped, although given th

3条回答
  •  萌比男神i
    2020-12-15 09:27

    Figured this out, the issue was that while I was setting the listSelector for the ListView to the State List correctly via android:listSelector="@drawable/list_selector", I also needed to set the background for the list item to another State List via android:background="@drawable/list_background"

    In the list_background.xml state list, I have:

    
    
    
        
    
    
        
        
    
        
        
    
    

    Found the answer here:

    Changing background color of ListView items on Android

    In conjunction with my list selector above, it works perfectly.

提交回复
热议问题