-
-
Save rvdlesk/721f73cb3d9374de1f26b9b06a3fbb2d to your computer and use it in GitHub Desktop.
Date/Time Picker fix for ScrollView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mydriver.customer.ui.common.custom; | |
import android.content.Context; | |
import android.util.AttributeSet; | |
import android.view.MotionEvent; | |
import android.view.View; | |
import android.view.ViewParent; | |
import android.widget.DatePicker; | |
/** | |
* Custom implementation of {@link DatePicker} to fix issue with {@link android.widget.ScrollView}. | |
* Disallows touch event for parent when touched on picker. | |
* | |
* Creator: <[email protected]> | |
* Date: 9/19/13 | |
* | |
*/ | |
public class CustomDatePicker extends DatePicker { | |
public CustomDatePicker(Context context) { | |
super(context); | |
} | |
public CustomDatePicker(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
public CustomDatePicker(Context context, AttributeSet attrs, int defStyle) { | |
super(context, attrs, defStyle); | |
} | |
@Override | |
public boolean onInterceptTouchEvent(MotionEvent ev) { | |
ViewParent parentView = getParent(); | |
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) { | |
if (parentView != null) { | |
parentView.requestDisallowInterceptTouchEvent(true); | |
} | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment