如何使用BigNerdRanch展开父文件夹展开Recyclerview库

时间:2018-07-30 21:21:39

标签: android android-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);
}

我需要在单击另一个parentGroup后如何折叠组。

1 个答案:

答案 0 :(得分:0)

仅更新库

'com.bignerdranch.android:expandablerecyclerview:1.0.3'

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

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