Android-pickerView时间选择器封装

轩辕季同
2023-12-01
public abstract class TimePickerView {

    private TYPE dateType;
    private Activity activity;
    private boolean isDialog=false;

    public enum TYPE {
        SECOND, MINUTE, HOUR, DAY, MINUTE_SECOND,YEAR_MONTH
    }

    public TimePickerView(TYPE dateType, Activity activity) {
        this.dateType = dateType;
        this.activity = activity;
        getTimeWithType();
    }

    public TimePickerView(TYPE dateType, Activity activity, boolean isDialog) {
        this.dateType = dateType;
        this.activity = activity;
        this.isDialog = isDialog;

        getTimeWithType();
    }

    private void getTimeWithType() {
        boolean[] type = new boolean[0];//控制时间的显示类型
        if (dateType.equals(TYPE.SECOND)) {
            //秒
            type = new boolean[]{true, true, true, true, true, true};
        } else if (dateType.equals(TYPE.HOUR)) {
            //时
            type = new boolean[]{true, true, true, true, false,
 类似资料: