How Can I Requestdisallowtouchevents On Android Drawerlayout
Solution 1:
You can use a flag. There is a method onDrawerSlide on the DrawerListener, that is called when your drawers position changes, i.e. the drawer is running to open or close itself. You can set in this method a flag indicating that the drawer is running. Then, on the onFling method of the OnGestureListener just show if the drawer is running by checking the flag. If it is not running, you can do whatever you want in the onFling method, if not, dont do anything.
I hope it helps
http://developer.android.com/reference/android/support/v4/widget/DrawerLayout.DrawerListener.html#onDrawerSlide(android.view.View, float)
Solution 2:
Not sure if you solved this, but make sure that your onTouch(View view, MotionEvent motionEvent){...} method returns true to indicate that the initial event is handled, otherwise the drawer layout is going to get the initial touch start event and gobble the next ones no matter what you pass to requestDisallowInterceptTouchEvents.
Unfortunately the BasicGestureDetect example in the SDK returns false from this method, which is fine when nothing else is around to steal those events and you're just logging them, but if you copy pasted that code into your app expecting it to work (like me), you're not going to get anything except the initial touch start.
So this section inside MainActivity from the BasicGestureDetect example:
actionFragment.getView().setOnTouchListener(newView.OnTouchListener() {
@OverridepublicbooleanonTouch(View view, MotionEvent motionEvent) {
gd.onTouchEvent(motionEvent);
returnfalse;
}
});
should instead be:
actionFragment.getView().setOnTouchListener(newView.OnTouchListener() {
@OverridepublicbooleanonTouch(View view, MotionEvent motionEvent) {
gd.onTouchEvent(motionEvent);
returntrue;
}
});
Post a Comment for "How Can I Requestdisallowtouchevents On Android Drawerlayout"