RecyclerView getChildCount 和 LinearLayoutManager.getItemCount

问题描述

RecyclerView.getChildCount()linearlayoutmanager.getItemCount() 有什么区别?
如果我理解正确,前者是创建和回收的视图数量,而后者是支持回收视图的数组中的项目数量? IE。实际数据?
这是正确的吗?

解决方法

RecyclerView.getChildCount() 将只返回屏幕上可见视图的数量,而不是回收的视图,并且是 LinearLayoutManager.getItemCount 将在内部调用适配器的 getItemCount() 如果附加了任何适配器并返回提供给 Adapter 的数据源中的实际项目数。