I have an ImageView
inside a RelativeLayout
.It gets images from database
.I want to add scroll-event to it such that when image is scrolled I should get next and previous image based on direction of scroll.
How can I do that in android?
I have an ImageView
inside a RelativeLayout
.It gets images from database
.I want to add scroll-event to it such that when image is scrolled I should get next and previous image based on direction of scroll.
How can I do that in android?
Example for implementing the onScrollListner
as per below code -
//Here is where the magic happens
this.getListView().setOnScrollListener(new OnScrollListener(){
//useless here, skip!
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {}
//dumdumdum
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount)
{
//what is the bottom iten that is visible
int lastInScreen = firstVisibleItem + visibleItemCount;
//is the bottom item visible & not loading more already ? Load more !
if((lastInScreen == totalItemCount) && !(loadingMore)){
Thread thread = new Thread(null, loadMoreListItems);
thread.start();
}
}
});
Have a look at this example and you can also use this Lazy load of images in ListView also