Reputation:
I have a simple layout, a listview, and two icons for filtering and sorting options. When I click on the either of the two options I have a layout that is placed above the listview and covers only 60% of the screen thereby making the listview below it partially visible. What I want to achieve is to disable the scrolling for that listview also, none of the listview item should be clickable as long as the overlay is visible.
I tried using
setEnabled(false)
setClickable(false)
on the listview but it doesn't make any difference. What are other ways to achieve this.
Upvotes: 5
Views: 2067
Reputation: 56
You can use this for disabling the parent scrollview
parentview.requestDisallowInterceptTouchEvent(true);
if the overlay is visible .
Upvotes: 0
Reputation: 5140
I suggest that the overlay will be on the whole screen. Then, you can wrap the overlay with (vertical) linear layout with weights (to achieve 60%/40% ratio). In the linear layout, place your current overlay as the first child and as a second child put a transparent view that will block touch events. This way you won't need to do any modifications to the list view.
Upvotes: 1
Reputation: 11873
To disable the scrolling you can use the 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);
For disabling the click, In your custom ArrayAdapter override isEnabled method as following
@Override
public boolean isEnabled(int position) {
return false;
}
Upvotes: 0