ListView listView = findViewById(R.id.listview); listView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() { @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { // called when an item is checked or unchecked } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { // called when the contextual action mode is created return true; } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { // called when the contextual action mode is about to be shown return true; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { // called when a contextual action mode menu item is clicked return true; } @Override public void onDestroyActionMode(ActionMode mode) { // called when the contextual action mode is destroyed } });In this example, we have a ListView with the ID "listview". We are setting the MultiChoiceModeListener for this ListView, and implementing the five methods that are called when the context action mode is created, prepared, an item is checked, an action item is clicked, or the mode is destroyed. Package library: android.widget.