Reputation: 788
When you use the ADT with Eclipse, and tell the ADT to create a new activity with a Master/Detail Flow, this method will appear in one of the fragments:
/**
* Turns on activate-on-click mode. When this mode is on, list items will be
* given the 'activated' state when touched.
*/
public void setActivateOnItemClick(boolean activateOnItemClick) {
// When setting CHOICE_MODE_SINGLE, ListView will automatically
// give items the 'activated' state when touched.
getListView().setChoiceMode(
activateOnItemClick ? ListView.CHOICE_MODE_SINGLE : ListView.CHOICE_MODE_NONE);
}
However, I want to implement a MultiChoiceModeListener
. Thus, that requires me to eliminate all references to this method, as it would remove the CHOICE_MODE_MULTIPLE_MODAL
that is required. However, I still want individual items to appear as 'activated' after selecting one of them from the list when the ActionMode
isn't active, since I am still displaying that item's details. (Obviously, switching when appropriate) Is there a way to go about do that?
Upvotes: 3
Views: 564
Reputation: 87064
However, I still want individual items to appear as 'activated' after selecting one of them from the list when the ActionMode isn't active, since I am still displaying that item's details. (Obviously, switching when appropriate) Is there a way to go about do that?
First of all, what you want to do seems a bit counter intuitive. You'll have a row activated when the contextual action bar isn't shown but you'll allow the user to select multiple rows(?!) when the CAB is present(what will happen with the details panel when the CAB is present and the user selects various rows?!). What will happen when the CAB is dismissed with multiple rows being selected(activated)? What will happen with the details panel when the CAB is dismissed?
Anyway, probably the easiest way to do what you want would be to keep the generated method(along with the choice mode) and lose the MultiChoiceListener
. Instead you'll be managing your own ActionMode
for the ListView
simulating the MultiChoiceModeListener
. That ActionMode
will be triggered from a OnItemLongClickListener
on the ListView
.
Upvotes: 1