Android TimePicker (Wheel Style) not responding co

2019-01-22 13:55发布

I have a dialog box that contains a Scrollview, which contains a layout with two TimePickers.

The timepickers are the newer style ones, what's in ICS.

The problem is that they seem to fight for focus when you change the time by dragging the wheel, or flicking it. It will change the time just a little, and then the layout will scroll instead.

Any ideas? Thanks in advance.

1条回答
做个烂人
2楼-- · 2019-01-22 14:53

I had the same problem when using the Holo theme, and here is where I found the solution: https://groups.google.com/forum/?fromgroups#!topic/android-developers/FkSfJI6dH8w

You must implement your custom DatePicker or TimePicker and override the following method:

@Override
public boolean onInterceptTouchEvent(MotionEvent ev)
{
    if (ev.getActionMasked() == MotionEvent.ACTION_DOWN)
    {
        ViewParent p = getParent();
        if (p != null)
            p.requestDisallowInterceptTouchEvent(true);
    }

    return false;
}
查看更多
登录 后发表回答