質問

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