MultichoiceModeListener on RecyclerView android

一世执手 提交于 2019-12-19 10:28:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!