Android的 - 在ListView选定的项目位置位置、项目、Android、ListView

2023-09-07 09:37:17 作者:迷失在人海

我怎样才能检索选定项目在multichoice ListView中的位置?在 getSelectedItemPosition 方法返回只有第一个。

How can I retrieve the positions of the selected item in a multichoice listView? The getSelectedItemPosition method returns only the first one.

推荐答案

有最多只有一个选择的项在的ListView

There is at most one selected item in a ListView.

如果你的的ListView CHOICE_MODE_SINGLE CHOICE_MODE_MULTIPLE ,您可以使用 getCheckedItemPositions()来获得的检查的人。

If your ListView is CHOICE_MODE_SINGLE or CHOICE_MODE_MULTIPLE, you can use getCheckedItemPositions() to get the checked ones.