Showing the current selection in a listview

后端 未结 4 847
旧巷少年郎
旧巷少年郎 2020-12-01 04:26

As seen in the tablet version of gmail and google talk I am trying to show the current selection in a listview. I know this is not standard practice and should be avoided wh

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 05:00

    What Gmail and similar apps use is the activated state, with an appropriate row layout. See:

    • Setting Android Background & Persistence Menu Bar - Using attribute on older versions causes crash - Is there a theme /pattern approach?
    • Change colour of activated list item background on Honeycomb

    In a nutshell, you:

    • Use a row layout with an activated background (e.g., android.R.layout.simple_list_item_activated_1)
    • Use setChoiceMode(ListView.CHOICE_MODE_SINGLE) on your ListView
    • "Check" the row that should be activated using setItemChecked() on your ListView to enable the "activated" state and have the persistent highlight

提交回复
热议问题