DatePickerDialog类的实例化需要用到回调接口,如下定义:
android.app.DatePickerDialog.DatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth)具体实例如:class="Apple-tab-span">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+"日");
}
};