Reputation: 1
I used the ListView with 4 items. when i click on the ListView items it shows the current selected item. But i need to implement the Scroll Listener to select the items in ListView . When i scroll the ListView it shows current scrolled item ? Any one help me with this
Upvotes: 0
Views: 352
Reputation: 190
Override the OnScrollListener
method in your ListView
Listener
list.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
if (list.getLastVisiblePosition() == totalItemCount - 1
) {
Toast.makeText(getActivity(), "Last", Toast.LENGTH_SHORT)
.show();
try {
} catch (Exception e) {
}
}
}
});
Upvotes: 1
Reputation: 1754
Implement OnScrollListener
for your ListView
@Override
public void onScroll(AbsListView absListView, int firstVisible, int visibleCount, int totalCount) {
//firstvisible is your first visible item in the list
}
Upvotes: 0