當前位置:編程學習大全網 - 源碼下載 - 如何在adapter裏調用顯示日期控件

如何在adapter裏調用顯示日期控件

參考代碼:

/**

?*?彈出日期對話框

?*?@param?textView

?*?@param?date?默認日期

?*/

public?void?showDateDialog(TextView?textView,?String?date)?{

txtDatePicker?=?textView;

calendar?=?Calendar.getInstance();

if?(!toolUtil.isBlank(date))?{

try?{calendar.setTime(dateUtil.formatDate().parse(date));}?catch?(Exception?e)?{}

}

new?DatePickerDialog(this,?new?DatePickerDialog.OnDateSetListener()?{

public?void?onDateSet(DatePicker?view,?int?year,?int?monthOfYear,?int?dayOfMonth)?{

calendar.set(Calendar.YEAR,?year);

calendar.set(Calendar.MONTH,?monthOfYear);

calendar.set(Calendar.DAY_OF_MONTH,?dayOfMonth);

txtDatePicker.setText(dateUtil.formatDate().format(calendar.getTime()));

}

},?calendar.get(Calendar.YEAR),?calendar.get(Calendar.MONTH),?calendar.get(Calendar.DAY_OF_MONTH)).show();

}

/**

?*?彈出時間對話框

?*?@param?textView

?*/

public?void?showTimeDialog(TextView?textView)?{

txtDatePicker?=?textView;

new?TimePickerDialog(this,?new?TimePickerDialog.OnTimeSetListener()?{

public?void?onTimeSet(TimePicker?view,?int?hourOfDay,?int?minute)?{

calendar.set(Calendar.HOUR_OF_DAY,?hourOfDay);

calendar.set(Calendar.MINUTE,?minute);

txtDatePicker.setText((hourOfDay?<?10"0"?+?hourOfDay?:?hourOfDay)?+?":"?+?(minute?<?10"0"?+?minute?:?minute)?+?":00");

}

},?calendar.get(Calendar.HOUR_OF_DAY),?calendar.get(Calendar.MINUTE),?true).show();

}

  • 上一篇:孕婦七個月時能吃菠菜嗎?如題 謝謝了
  • 下一篇:飛行助手源代碼
  • copyright 2024編程學習大全網