My requirement is simple. In my application there is a listview with chat messages and a arrow icon at top of the screen. New items will be added dynamically and i want to show this arrow icon when new message arrives by checking some conditions,
1. Arrow will be shown if listview is not at bottom (ie last item is not visible).
2. Arrow will be dismissed when user scrolls listview to bottom.
3. Arrow will not be showed if listview is at bottom.
I have used a boolean value for checking the position status of listvew, when new message arrives i am checking,
if(isAtBottom){
// Adding to list
mChatMessages.add(mNewMessage);
mAdapter.setListing(mChatMessages);
scrollListViewToBottom();
}else{
mChatMessages.add(mNewMessage);
mAdapter.setListing(mChatMessages);
startArrowIndicator();
}
And when user scrolls the listview the following code is used,
@Override
public void onScroll(AbsListView absListView, final int firstVisibleItem,
final int visibleItemCount, final int totalItemCount) {
final int lastItem = firstVisibleItem + visibleItemCount;
if(lastItem == totalItemCount) {
stopArrowIndicator();
isAtBottom = true;
}else{
isAtBottom = false;
}
}
But this code is not working.... Any idea..?