安卓原生的日期选择器

bt2.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
if (cd!=null)cd=null;
cd =Calendar.getInstance();
DatePickerDialog datePickerDialog = new DatePickerDialog(MainActivity.this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
cd.set(Calendar.YEAR,year);
cd.set(Calendar.MONTH,month);
cd.set(Calendar.DAY_OF_MONTH,dayOfMonth);
}

}, cd.get(Calendar.YEAR), cd.get(Calendar.MONTH), cd.get(Calendar.DAY_OF_MONTH));
datePickerDialog.show();
}
});
posted @ 2019-04-17 17:37  码弄  阅读(1105)  评论(0编辑  收藏  举报