I am trying to make my ListView update when the scroll is at the bottom of the screen, I have almost made it work but there is still a slight issue with the scroll.

First of all here is my code to detect the lastItem of ListView,

public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                currentFirstVisibleItem = firstVisibleItem;
                currentVisibleItemCount = visibleItemCount;
                ttc = totalItemCount;
                  // check if the current item is last,
                    if (currentFirstVisibleItem+currentVisibleItemCount == ttc){
                        Log.e("ss","I am here");
                        if (totalTime == timeConsumed){
                            // add data on listView
                            // update listView


When I execute the app , I scroll all the way to the bottom so that if (currentFirstVisibleItem+currentVisibleItemCount == ttc) condition become true, and it working because i am getting a message on Log.e I am here.

At this point, I am already at the bottom of the screen and wait for if (totalTime == timeConsumed) block to execute, which will execute after 5seconds. As soon as if (totalTime == timeConsumed) block is executed I get the Log message, Log.e("Last","Last"); because I am already at the bottom of the ListView, but the problem is, notifyDataSetChanged is not executed automatically eventhough I am already on the bottom of ListView, and in order to execute notifyDataSetChanged() i have to re-scroll to the bottom with my fingers, only then it is executed.

Why notifyDataSetChanged() is not executed when Log.e("Last","Last"); is executed ? even though I am already at the bottom of the screen ? Why I have to scroll up a little and scroll back down to make notifyDataSetChanged() execute ?

Related posts

Recent Viewed