0

I have a question. How should i stop scroll of list view in android as I want to scroll only with two buttons as named "up" and "down" Thanks in advance.

  • consider searching before asking a question. http://stackoverflow.com/questions/18613844/scrolling-listview-with-buttons – Hemanth May 18 '17 at 08:03

3 Answers3

0

You need to subclass your ListView and override the below method:

@Override public boolean dispatchTouchEvent(MotionEvent e) {
   if(e.getAction()==MotionEvent.ACTION_MOVE) {
      return true;    
   }

   return super.dispatchTouchEvent(e); 
 }
Anoop
  • 1,307
  • 1
  • 14
  • 27
0

Can handle by properties of list views to manage scrolling features

// to stop the scrolling of list view
listView.smoothScrollBy(0, 0); 

//to move to the specified specific position in listview
 listView.setSelection(listItemposition) 
Rakshith Kumar
  • 872
  • 8
  • 20
0

If you don't need to select rows from your ListView you can use:

listview.setEnabled(false)

Else, you need to override dispatchTouchEvent :

@Override public boolean dispatchTouchEvent(MotionEvent e) {
   if(e.getAction()==MotionEvent.ACTION_MOVE) {
      return true;    
   }
   return super.dispatchTouchEvent(e); 
}

Then, to implement your buttons you can use :

listview.smoothScrollToPosition(position);
LeDaheronF
  • 16
  • 1
  • 6