How to use MultiChoiceModeListener in ListVIew with and with out supports?
Asked Answered
I

1

7

I am trying to add multi-select context menu to a listview with support library 22.1.1 using AppCompatActivity and Toolbar

Without support library I can use AbsListView.MultiChoiceModeListener

with support library, There is no equivalent MultiChoiceModeListener exists for support version that accept android.support.v7.view.ActionMode as parameter.

What should I do to get it working with support library?

Instil answered 11/5, 2015 at 9:27 Comment(0)
N
0
Start `ActionMode` in `Activity`:

   ((AppCompatActivity)getActivity()).startSupportActionMode(new android.support.v7.view.ActionMode.Callback() {
            @Override
            public boolean onCreateActionMode(android.support.v7.view.ActionMode mode, Menu menu) {
                return false;
            }

            @Override
            public boolean onPrepareActionMode(android.support.v7.view.ActionMode mode, Menu menu) {
                return false;
            }

            @Override
            public boolean onActionItemClicked(android.support.v7.view.ActionMode mode, MenuItem item) {
                return false;
            }

            @Override
            public void onDestroyActionMode(android.support.v7.view.ActionMode mode) {

            }
        })

Use MultiSelector library:

https://github.com/bignerdranch/recyclerview-multiselect

http://ifeve.com/recyclerview-part-2%EF%BC%9A%E9%80%89%E6%8B%A9%E6%A8%A1%E5%BC%8F/

Necropolis answered 18/11, 2015 at 1:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.