是否有一种方法可以在扩展组时仅显示子项的子集,并允许用户滚动子项列表以访问Android ExpandableListView中的其余元素?
var shouldLimitChildrenCount:Boolean = true
override fun getChildrenCount(groupPosition: Int): Int {
if (shouldLimitChildrenCount) {
return 5 // show only 5 elements
}
return children.size // actual size
}
override fun onGroupExpanded(groupPosition: Int) {
shouldLimitChildrenCount = false
}
override fun onGroupCollapsed(groupPosition: Int) {
shouldLimitChildrenCount = true
}
尝试了上述方法,但是子级列表不会滚动,并且始终显示前5个子级项!