上述代码出现了此问题:Unresolved reference: getChildViewHolder

动态 未结 0 101
小小草
小小草 LV1 2023年9月23日 23:40 发表
getChildViewHolder()方法是RecyclerView.LayoutManager中的方法,需要继承RecyclerView.LayoutManager才能使用。如果你的LayoutManager不是继承自RecyclerView.LayoutManager,那么可以尝试使用RecyclerView的getChildViewHolderInt()方法来获取ViewHolder: ``` override fun onLayoutChildren(recycler: RecyclerView.Recycler?, state: RecyclerView.State?) { super.onLayoutChildren(recycler, state) var totalHeight = 0 for (i in 0 until childCount) { val child = mRvChat.getChildViewHolderInt(getChildAt(i)).itemView totalHeight += child.height } if (totalHeight > height) { mRvChat.postDelayed({ mRvChat.smoothScrollToPosition(itemCount - 1) }, 1000) } } ``` 这样就可以避免Unresolved reference: getChildViewHolder的问题了。
收藏(0)  分享
相关标签: 智能问答
问题没解决?让AI助手帮你作答 AI助手
0个回复
  • 消灭零回复