(1)getChildCount()
官方解释:Return the current number of child views attached to the parent RecyclerView
大概意思就是返回已经添加到RecyclerView的个数,并不是说数据的个数,这个方法大概的意思是由于RecyclerView有回收的机制,有时候我们需要知道RecyclerView当前添加的子view的数量的时候,可调用该方法。
(2)getItemCount()
官方解释:Returns the number of items in the adapter bound to the parent RecyclerView.
我总是把这个方法跟上面那个方法搞混,这个方法就是你在adapter中绑定的数据长度,adapter也有个getItemCount(),其实就是调用这个方法,我们在这个方法返回的值。
RecyclerView ---LayoutManager
最新推荐文章于 2021-05-06 18:26:30 发布