我已经在我的片段上实现了日期选择器,这是代码:
edittext_from.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
android.app.DatePickerDialog datePickerDialog = new android.app.DatePickerDialog(getContext(),
new android.app.DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
edittext_from.setText(String.format("%04d-%02d-%02d", year, (monthOfYear + 1), dayOfMonth));
}
}, mYear, mMonth, mDay);
datePickerDialog.show();
}
});
我想使用具有材质风格的 DatePicker,我尝试使用这个库 compile 'com.wdullaer:materialdatetimepicker:2.3.0'
,但结果是一样的。有什么帮助我可以用 Material Date Picker 更改这个 DatePicker 吗?谢谢