懒得写文章了
看效果:
关键代码(利用recyclerview插入以及移除item的方式实现):
override fun openState(areaParent: AreaItemView, position: Int) {
if (areaParent.child != null && areaParent.child.size > 0) {
mListData.addAll(position + 1, areaParent.child)
areaParent.foldedState = false
notifyItemRangeInserted(position + 1, areaParent.child.size)
notifyItemChanged(position)
}
}
override fun closeState(areaParent: AreaItemView, position: Int) {
if (areaParent.child != null && areaParent.child.size > 0){
mListData.subList(position + 1, position + 1 + areaParent.child.size).clear()
areaParent.foldedState = true
notifyItemRangeRemoved(position + 1, areaParent.child.size)
notifyItemChanged(position)
}
}
项目地址:
GitHub项目Demo地址