android - 如何使用 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);
}
单击另一个父组后,我需要如何折叠组。
解决方案
只更新库
'com.bignerdranch.android:expandablerecyclerview:1.0.3'
至
'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'
并重构(编辑)名称 java 类。
推荐阅读
- colors - if/else 的 Guppy 颜色变化问题。如何解决?
- python - Django 模板。整数迭代的最佳方法
- r - R:根据条件将函数应用于两个不同的表(空间连接)
- python - 如何在映射多个 Foursquare 结果且 API 结果为空时数据框为空时在 Python 中抑制 KeyError
- python - 绘制熊猫数据框
- jenkins - Sonarqube 扫描获取整个代码或仅获取哈希值
- javascript - Ion.RangeSlider。解析值的问题
- r - R Unite 函数在 Shiny 与代码中的行为不同
- kubernetes - Istio/Envoy 边缘代理 EnvoyFilter (1.9.0)
- python - 通过复制数组中的每个项目来创建新的 numpy 数组