Android disable scrolling and click to view list

I have a simple layout, a list, and two icons for filtering and sorting. When I click on one of the two options, I have a layout that is placed above the list and covers only 60% of the screen, thereby making it visible below. What I want to achieve is to disable scrolling for this list as well, no list item should be clickable while the overlay is displayed.

I tried to use

setEnabled(false) setClickable(false) 

on the list, but it does not matter. What are other ways to achieve this.

+5
source share
3 answers

You can use this to disable parent scroll

parentview.requestDisallowInterceptTouchEvent (true);

if the overlay is visible.

0
source

I suggest that the overlay be on the whole screen. You can then overlay an overlay (vertical) linear layout with weights (to achieve a 60% / 40% ratio). In the linear layout, place the current layer overlay as the first child, and the second - put a transparent view that will block touch events. This way you will not need to make any changes to the list view.

+1
source

To disable scrolling, you can use OnTouchListener ()

 listView.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_MOVE) { return true; // Indicates that this has been handled by you and will not be forwarded further. } return false; } }); 

OR

 listView.setScrollContainer(false); 

To disable click, in your custom override, ArrayAdapter isEnabled, as shown below:

 @Override public boolean isEnabled(int position) { return false; } 
0
source

All Articles