RecyclerView Android上的MultichoiceModeListener [英] MultichoiceModeListener on RecyclerView android

查看:85
本文介绍了RecyclerView Android上的MultichoiceModeListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有相应适配器的recyclerview.我想在长按recyclerview项目时在工具栏中显示多个customview菜单选项. 任何帮助都将受到高度赞赏.预先感谢.

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.

推荐答案

我正在做同样的工作.这篇文章很有帮助:带有选择模式的RecyclerView

I'm doing the same work. This post is helpful: RecyclerView with choice modes

基本上,您必须在OnLongClick方法中添加此代码

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;
}

希望有帮助

这篇关于RecyclerView Android上的MultichoiceModeListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆