0

I am trying to auto scroll listview till reach to bottom. Listview should be scroll slowly like animation. I am using below code for scroll listview and listview auto scrolling working but problem is that listview not scrolling till reach to bottom at the mid way listview stop scrolling

 orderlistview.smoothScrollToPositionFromTop(orderlist.size(), 0, 2000);
Hitesh Gehlot
  • 1,307
  • 1
  • 15
  • 30
  • 1
    Possible duplicate of [Listview Scroll to the end of the list after updating the list](https://stackoverflow.com/questions/3606530/listview-scroll-to-the-end-of-the-list-after-updating-the-list) – Rajasekhar Oct 12 '17 at 10:56
  • @Rajasekhar i want scroll to bottom slowly not instant – Hitesh Gehlot Oct 12 '17 at 12:06

1 Answers1

-1

Try this

int index = 1;
int listviewCount = mAdapter.getCount(); 
Runnable runnable;
int ANIMATION_TIME = 1000;

Handler handler = new Handler();
    handler.postDelayed(runnable = new Runnable() {
        @Override
        public void run() {
         if(listviewCount >= index){
           handler.removeCallbacks(runnable);
         } else {
           orderlistview.smoothScrollToPosition(index);
           index = index + 1;  
           handler.postDelayed(runnable , ANIMATION_TIME);
         } 
      }
    }, 0);

Remove callbacks in onPause()

 handler.removeCallbacks(runnable);
Rajasekhar
  • 2,345
  • 1
  • 13
  • 20