1
我試圖顯示頁腳在RecyclerView infinte滾動,但頁腳有時顯示如此之快,有時它並不顯示在所有。是否在給定的代碼有問題?RecyclerView頁腳不顯示
public class CustomRecyclerViewScrollListener extends RecyclerView.OnScrollListener {
int visibleCount = 0;
int totalItemCount = 0;
int pastVisibleItems = 0;
int lastVisibleItem=0;
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
visibleCount = llm.getChildCount();
totalItemCount = llm.getItemCount();
pastVisibleItems = llm.findFirstVisibleItemPosition();
lastVisibleItem=llm.findLastVisibleItemPosition();
if (!isLoading && !dataFinished && list.size() % 10 == 0) {
if ((visibleCount + pastVisibleItems) >= totalItemCount) {
isLoading = true;
loadMore();
adapter.showViewHolderFooter();
}
}
} else {
adapter.hideViewHolderFooter();
}
}
你可能要開始之前顯示'loadMore'前軀。 –