Reputation: 1185
I know there are several answers which describe how to lock a ViewPager
.
But I want that my ViewPager
is able to scroll only if the touch doesn't occour on a specific child.
So how can I "filter" out which child views are touched?
example code of how I want to lock my ViewPager
:
for (Integer resource:mResources) {
if(resource.intValue()==view.getId()){
touchTriggeredOnView(view.getId());
}
}
The reason why I want to do this is, that I have a custom view which needs to detect fling gestures.
This custom view is a child of a Fragment
and the Fragment
is a child of the ViewPager
.
So: ViewPager
->Fragment
->CustomView
.
I'm able to detect the DOWN
but not the FLING
event inside my CustomView
.
I think that the ViewPager
captures the FLING
event --> bad thing.
I hope that my question is clear enough.
Upvotes: 2
Views: 986
Reputation: 3850
onTouch and gesture listeners in Android have boolean return values which indicate whether event (touch, fling, click) is consumed or not.
ViewPager probably consumes "Fling" event, however you could override onTouch, gesture listener in ViewPager and return false - thus not consuming touch event and passing it to your custom view.
Upvotes: 2