Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable scrolling in listview

I have a list view and depending on some logic I want to temporary disable the scrolling. view.setOnScrollListener(null); doesn't helps me I guess I need to write some code, can someone give me a hist or some snippet ?

Thanks

like image 780
Lukap Avatar asked Sep 30 '11 13:09

Lukap


People also ask

How do I make my list view not scrollable?

You can make the ListView widget never scrollable by setting physics property to NeverScrollableScrollPhysics().

How do you stop scrolling in grid view Flutter?

You can provide physics: NeverScrollableScrollPhysics() on GridView to disable scroll effect. If you want scrollable as secondary widget use primary: false, To have Full Page scrollable, you can use body:SingleChildScrollView(..) or better using body:CustomScrollView(..) Save this answer.

How do I turn off SingleChildScrollView Flutter?

You can use the following code in your singleChildScrollView. physics: NeverScrollableScrollPhysics(), It stops it from being able to scroll.


2 Answers

Another option without creating a new custom ListView would be to attach an onTouchListener to your ListView and return true in the onTouch() callback if the motion event action is ACTION_MOVE.

listView.setOnTouchListener(new OnTouchListener() {      public boolean onTouch(View v, MotionEvent event) {         return (event.getAction() == MotionEvent.ACTION_MOVE);     } }); 
like image 180
Surya Wijaya Madjid Avatar answered Oct 12 '22 02:10

Surya Wijaya Madjid


In your CustomListView:

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

Then ListView will react to clicks, but will not change scroll position.

like image 38
Pointer Null Avatar answered Oct 12 '22 04:10

Pointer Null