ListView item background via custom selector

前端 未结 10 1578
深忆病人
深忆病人 2020-11-22 08:19

Is it possible to apply a custom background to each Listview item via the list selector?

The default selector specifies @android:color/transparent for t

10条回答
  •  广开言路
    2020-11-22 09:16

    I always use the same method and it works every time, every where: I simply use a selector like this

    
    
    
    

    and set on the ListView (THIS IS VERY IMPORTANT TO MAKE IT WORKING) the attribute

    android:choiceMode="singleChoice"
    

    for the textColor just put in the color folder(IMPORTANT, not drawable folder!) a selector like this

    
    
    
    

    this a sample row template

    
    
    
    

    everything showld work without tedious workarounds. hope this help

提交回复
热议问题