1

I have a ListView in which, as the question suggests, I am loading images with a delay. The problem is that this method is overriding my custom onScrollListener. I tried using:

aq.id(listview).scrolled(new customScrollListener());
aq.id(listview).adapter(myAdapter);

These two lines are in the calling activity class, and I do this after I have loaded all data in the list. Even after this the scrollListener doesn't seem to be working. Where am I going wrong? Any ideas?

UPDATE - 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) {
}       
}
Rameez Hussain
  • 6,414
  • 10
  • 56
  • 85

1 Answers1

0

Your problem is that AndroidQuery souldDelay will override your own listener. Look at the docs:

The shouldDelay() method uses the setOnScrollListener() method and will override any previously non-aquery assigned scroll listener. If a scrolled listener is required, use the aquery method scrolled(OnScrollListener listener) to register your listener instead.

source: aquery image loading

Martin Marconcini
  • 26,875
  • 19
  • 106
  • 144