当前位置:   article > 正文

Android自定义DataTimePicker(日期选择器),androidstudio插件开发_android datepicker 设置初试日期

android datepicker 设置初试日期

initDateTime = calendar.get(Calendar.YEAR) + “年”

  • calendar.get(Calendar.MONTH) + “月”

  • calendar.get(Calendar.DAY_OF_MONTH) + "日 "

  • calendar.get(Calendar.HOUR_OF_DAY) + “:”

  • calendar.get(Calendar.MINUTE);

}

datePicker.init(calendar.get(Calendar.YEAR),

calendar.get(Calendar.MONTH),

calendar.get(Calendar.DAY_OF_MONTH), this);

timePicker.setCurrentHour(calendar.get(Calendar.HOUR_OF_DAY));

timePicker.setCurrentMinute(calendar.get(Calendar.MINUTE));

}

/**

  • 弹出日期时间选择框方法

  • @param inputDate

  •        :为需要设置的日期时间文本编辑框
    
    • 1
  • @return

*/

public AlertDialog dateTimePicKDialog(final EditText inputDate) {

LinearLayout dateTimeLayout = (LinearLayout) activity

.getLayoutInflater().inflate(R.layout.common_datetime, null);

datePicker = (DatePicker) dateTimeLayout.findViewById(R.id.datepicker);

timePicker = (TimePicker) dateTimeLayout.findViewById(R.id.timepicker);

init(datePicker, timePicker);

timePicker.setIs24HourView(true);

timePicker.setOnTimeChangedListener(this);

ad = new AlertDialog.Builder(activity)

.setTitle(initDateTime)

.setView(dateTimeLayout)

.setPositiveButton(“设置”, new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/817334
推荐阅读
相关标签
  

闽ICP备14008679号