首页 > 解决方案 > 如何使用 BigNerdRanch 折叠父级展开 Recyclerview 库

问题描述

与 Big Nerd Ranch 回收商合作:扩展库

'com.bignerdranch.android:expandablerecyclerview:1.0.3'

RecyclerAdapter.Java代码中...

 @Override
public void onParentItemClickListener(int position) {
    /**
     * @Params
     * Se comienza en -1, al clickear el primer grupo, se registra en la variable su posicion
     * al clickear el siguiente grupo, si la variable no es igual a su posicion se procede a
     * cerrar el grupo anterior.
     * */

    Object parent = mParentItemList.get(position);
    //Toast.makeText(mContext,"posicion "+String.valueOf(position),Toast.LENGTH_SHORT).show();

    if(lastExpanded == -1){
        lastExpanded = position;

    } else if(lastExpanded == position){
        lastExpanded = -1; //Reinicia Variable

        notifyItemChanged(position);
    }else{
        //Cierra grupo abierto
        int oldExpand = lastExpanded;
        Toast.makeText(mContext,"se cerro  "+String.valueOf(oldExpand),Toast.LENGTH_SHORT).show();
        lastExpanded = position;

        **//Need the colapse group code**

        notifyItemChanged(oldExpand);
        notifyItemChanged(position);
    }

    super.onParentItemClickListener(position);
}

单击另一个父组后,我需要如何折叠组。

标签: androidandroid-recyclerview

解决方案


只更新库

'com.bignerdranch.android:expandablerecyclerview:1.0.3'

'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'

并重构(编辑)名称 java 类。


推荐阅读