DatePickerDialog类的实例化需要用到回调接口,如下定义:

android.app.DatePickerDialog.DatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth)

具体实例如:Dialog dialog=new DatePickerDialog(MainActivity.this, datePickerListener, 1990, 04, 01);

 

//datePickerListener 是一个回调接口,可以如下定义:

DatePickerDialog.OnDateSetListener datePickerListener = new OnDateSetListener() {
  public void onDateSet(DatePicker view, int year, int monthOfYear,int dayOfMonth) {
  textView.setText("更新日期为:"+year+"年-"+(monthOfYear+1)+"月-"+dayOfMonth+"日");
  }
};

 

相关文章:

  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
  • 2021-04-17
猜你喜欢
  • 2021-12-17
  • 2022-12-23
  • 2021-11-23
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案