Listview getChildAt方法返回null以及精确判断滚动到底部

mac2022-06-30  25

1:getChildAt释疑:

  getChildAt(int index)得到的是当前ListView可见项的item,index为可见项的索引;

  getChildCount返回的是ListView当前屏幕下可见项的数目

 getChildAt中index的大小并非为ListView的Adapter中的index,而是0~getChildCount()之间的值,否则返回为null

2:判断滚动到底部

 if (getCount() - 1 == getLastVisiblePosition() && getChildAt(getChildCount() - 1).getBottom() <= getHeight()) {

   // TODO  }

转载于:https://www.cnblogs.com/Professionalbutcher/p/3777716.html

最新回复(0)