Created
September 20, 2013 04:16
-
-
Save izmajlowiczl/6633221 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: <lukasz.izmajlowicz@mydriver.com> | |
* 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; | |
} | |
} |
Do you have a CustomTimePicker too? :D
Or does this work for both?
I know I'm lazy for not trying.
please don't judge me
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot ....It really works....:)