How to highlight row in ListView in Android?

后端 未结 8 1505
天涯浪人
天涯浪人 2020-11-27 06:05

I need to highlight a row in a ListView that was selected (to show the user what he chose), so, it\'s not the one that is going to be chosen, it\'s the one he c

8条回答
  •  臣服心动
    2020-11-27 06:16

    Just:

    1. Set the correct choice mode in your list view. setChoiceMode
    2. Set a background to support the selection state in you item layout, like:

      android:background="?android:attr/activatedBackgroundIndicator"
      

    FYI:

    • http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList
    • http://android-developers.blogspot.mx/2008/12/touch-mode.html

提交回复
热议问题