问题
I have a recyclerview with respective adapter. I want to show multiple customview menu options in toolbar on the long press of recyclerview item. Any help is highly appreciated. Thanks in advance.
回答1:
I'm doing the same work. This post is helpful: RecyclerView with choice modes
Basically you have to add this code in your OnLongClick method
@Override
public boolean onLongClick(View view) {
if (!mMultiSelector.isSelectable()) {
((AppCompatActivity) getActivity()).startSupportActionMode(mActionModeCallback); // (2)
mMultiSelector.setSelectable(true);
mMultiSelector.setSelected(MyViewHolder.this, true);
return true;
}
return false;
}
Hope it helps
来源:https://stackoverflow.com/questions/37389294/multichoicemodelistener-on-recyclerview-android