build.gradle(Module:app)

1
implementation 'net.codecrafted:lineartimepicker:1.0.0' // 线性日期时间选择器

日期选择 .java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
boolean data_tutorial = false; // 是否出现使用帮助
if (SettingsUtil.getInt(getApplicationContext(), "LinearDatePicker_tutorial") != 1) {
data_tutorial = true;
}
LinearDatePickerDialog.Builder.with(RecordActivity.this)
.setYear(addYear)
.setMinYear(2000)
.setMaxYear(2030)
.setShowTutorial(data_tutorial)
.setButtonCallback(new LinearDatePickerDialog.ButtonCallback() {
@Override
public void onPositive(DialogInterface dialog, int year, int month, int day) {
SettingsUtil.setVal(getApplicationContext(), "LinearDataPicker_tutorial", 1);
/*...code...*/
}

@Override
public void onNegative(DialogInterface dialog) {

}
})
.build()
.show();

时间选择 .java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
boolean time_tutorial = false;
if (SettingsUtil.getInt(getApplicationContext(), "LinearTimePicker_tutorial") != 1) {
time_tutorial = true;
}
LinearTimePickerDialog dialog = LinearTimePickerDialog.Builder.with(RecordActivity.this)
.setShowTutorial(time_tutorial)
.setButtonCallback(new LinearTimePickerDialog.ButtonCallback() {
@Override
public void onPositive(DialogInterface dialog, int hour, int minutes) {
SettingsUtil.setVal(getApplicationContext(), "LinearDataPicker_tutorial", 1);
/*...code...*/
}

@Override
public void onNegative(DialogInterface dialog) {

}
})
.build();
dialog.show();