selected item on custom listview with contextual action bar

后端 未结 4 2004
一整个雨季
一整个雨季 2021-01-30 10:51

I recently started using android actionbars and contextual action bars (CAB).

I have just one activity which is a ListActivity. Basically I use the following code snippe

4条回答
  •  没有蜡笔的小新
    2021-01-30 11:26

    I've only ever tested this in CHOICE_MODE_SINGLE, but in that situation it works by doing the following.

    • When you select a list item, in code, call "setItemChecked(position, checked)" method (on the ListView instance) for that item in the list.

    • Add this to the XML for individual ListView items:
      android:background="?android:attr/activatedBackgroundIndicator"

提交回复
热议问题