I want to make recyclerview item click like this image.When i selected recyclerview item press long click then contextual action mode is enable.If i select only one item then show edit menu item else not.I want when i click edit menu item then click on recyclerView selected item and do some work.But i can't do it.Please help me some one.I am a new in android development. Advanced Thank you.
I grab some info for you, that might be help for you,
Once setSelectable() is implemented, you can achieve the rest of CHOICE_MODE_MULTIPLE_MODAL by using a regular ActionMode.Callback . Call through to your setSelectable() from within the relevant callback methods:
private ActionMode.Callback mDeleteMode = new ActionMode.Callback() {
@Override
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
setSelectable(true);
return false;
}
@Override
public void onDestroyActionMode(ActionMode actionMode) {
setSelectable(false);
}
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) { ... }
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { ... }
}
Then use a long click listener to turn on the action mode:
private class CrimeHolder extends SwappingHolder
implements View.OnClickListener, View.OnLongClickListener {
...
public CrimeHolder(View itemView) {
...
itemView.setOnClickListener(this);
itemView.setOnLongClickListener(this);
itemView.setLongClickable(true);
}
@Override
public boolean onLongClick(View v) {
ActionBarActivity activity = (ActionBarActivity)getActivity();
activity.startSupportActionMode(mDeleteMode );
setSelected(this, true);
return true;
}
}
Let me know if you have any idea from this snippet. if you want more go this link , which is great article by Bill Phillips .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.