i have a problem with a custom ListView-Adapter. So I'm trying to start the ActionMode of ActionBarSherlock, when a Checkbox (Every Listitem has one) is checked. I implemented an OnClickListener directly in the adapter:
((CheckBox) holder.check_entry).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//code
}
});
How can I start the ActionMode correctly?
I hope you can help me.
Get a reference to the activity and call Activity#startActionMode(ActionMode.Callback callback)
. As parameter you need to pass an implementation of the ActionMode.Callback
interface. Check out the ActionMode sample of ActionBarSherlock.
By the way, regarding the ListView
with checkboxes, I would take a look at android:choiceMode
and ListView#isItemChecked(int position)
.