문제

I have a listview and have implemented the MultiChoice mode to be MultipleModal and set a MultiChoiceModeListener via

'listView.SetMultiChoiceModeListener(this)` and then had my activity implement the interface.

I would like to have an action bar item that when clicked, toggles on the listview multi choice mode as a way for non savvy users to discover this feature.

How can I accomplish this?

EDIT: When calling 'listView.startActionMode(this)' the contextual action bar will appear, but the list view responds to click events like normal rather than highlighting them like I want.

도움이 되었습니까?

해결책

I figured it out.

Calling listView.setItemChecked(-1, true); causes it to appear automatically due to a checked state change which is what the default long click does.

I believe the end result will indeed put a key with -1 into the SparseBooleanArray returned by getCheckedItemPositions(), but when iterating over that array I pull indexes from a loop that starts at 0 and goes up to my ListView's item count and thus will never check negative keys.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top