Battlestr1k3
Battlestr1k3

Reputation: 91

Start ActionMode() from Listadapter

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.

Upvotes: 1

Views: 1291

Answers (1)

Matthias Robbers
Matthias Robbers

Reputation: 15728

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).

Upvotes: 1

Related Questions