首页 > 解决方案 > Why getItemCount() called multiple times in recycleView?

问题描述

Pls suggest. I am unable to find anything written in developer.android.com about this. If anyone help is highly appreciable.

Thanks in advance.

标签: androidandroid-recyclerview

解决方案


getItemCount() - 返回适配器中当前可用的项目数

此方法返回包含您要显示的项目的集合的大小,如@CommonsWare 所说(完全正确)。

@Override
public int getItemCount() {
    return listofitems.size();
}

为了给您搜索到的参考资料,请看这里:

希望有助于澄清。干杯:)


推荐阅读