What the purpose of the getSelectedItem() from the ListView

前端 未结 2 1024
旧巷少年郎
旧巷少年郎 2021-01-25 03:52

What the purpose of the getSelectedItem() from the ListView if a list can\'t keep state of a selected item ?

相关标签:
2条回答
  • 2021-01-25 04:08

    It can keep track of a selected item if you were to use say, a checkbox or a checkedtextview, but if you want to keep track of your selected items via a "highlighted background", then it's not possible (unless you want to have a hidden checkbox)

    0 讨论(0)
  • 2021-01-25 04:17

    getSelectedItem() is actually quite useless for ListView. getSelectedItem is defined in AdapterView, so there are other widgets that make better use of this method.

    If you need to access the current item when it's selected, set the appropriate OnItemClickListener or OnItemLongClickListener.

    0 讨论(0)
提交回复
热议问题