1 . 實作 DatePickerDialog
Calendar calendar0 = Calendar.getInstance();
DatePickerDialog dialog0 = new DatePickerDialog(this, this,
calendar0.get(Calendar.YEAR), calendar0.get(Calendar.MONTH),
calendar0.get(Calendar.DAY_OF_MONTH));
dialog0.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
dialog0.show();
2 . 實作 DatePickerDialog
....implements implements DatePickerDialog.OnDateSetListener{ ... }
3 . 接回參數
// CallBack
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
Log.d("DateTest","Date : " + format.format(new Date()));
}
歡迎轉載,請註明出處。
沒有留言:
張貼留言