1
我有一個ListView,其中,如問題所示,我加載圖像時有延遲。問題是這個方法重寫了我的自定義onScrollListener。我試着使用:AQuery shouldDelay和滾動監聽器
aq.id(listview).scrolled(new customScrollListener());
aq.id(listview).adapter(myAdapter);
這兩行代碼在調用活動類,而我做到這一點我已加載列表中的所有數據之後。即使在這之後,scrollListener似乎也沒有工作。我哪裏錯了?有任何想法嗎?
更新 - CustomScrollListener:
private class CustomScrollListener implements OnScrollListener {
private Context context;
private int visibleThreshold = 0;
private int currentPage = 0;
private int previousTotal = 0;
private boolean loading = true;
CustomScrollListener(Context context) {
this.context = context;
}
CustomScrollListener(int visibleThreshold) {
this.visibleThreshold = visibleThreshold;
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
if (loading) {
if (totalItemCount > previousTotal) {
loading = false;
previousTotal = totalItemCount;
currentPage++;
}
}
if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold) && totalItemCount>10) {
// do something
}
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
}
發表您的customScrollListener代碼 – petey
代碼添加。請看一看。 :) –
Hm,看起來像你的滾動監聽器添加好,嘗試添加一些'Log.d(「TAG」,「fooo」);'在你的if邏輯中和周圍記錄語句以查看該部分是否工作正常。 – petey