1

这是我的自定义号码选择器

公共类 CustomNumberPicker 扩展 NumberPicker {

public CustomNumberPicker(Context context) {
    super(context);
    // TODO Auto-generated constructor stub
}

public CustomNumberPicker(Context context, AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
}

public CustomNumberPicker(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    // TODO Auto-generated constructor stub
}

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

    return false;
}

}

因为这个数字选择器在滚动视图中,并且很难滚动数字,所以我重写了 onInterceptTouchEvent()。这种自定义方法在 TimePicker 上运行良好。但是自定义后,数字选择器不能滚动,但是向上箭头和向下箭头效果很好。有没有人可以解决这个问题?谢谢!!!!!!

4

0 回答 0