Android日期选择器实例代码详解

时间:2017-06-03 05:52:59 

废话不多说了,直接给大家贴代码了,具体代码如下所示:

//出生年月设置 private void birthSetting() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_YEAR, 1); new DatePickerDialog(mContext, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { String month = (monthOfYear + 1) < 10 ? "0" + String.valueOf(monthOfYear + 1) : String.valueOf(monthOfYear + 1); tvBirth.setText(new StringBuilder().append(year).append("-").append(month).append("-").append(dayOfMonth));//tvBirth就是选择日期结果textview } }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)).show(); }

看不过瘾?点击下面链接!
本站微信公众号:gsjx365,天天有好故事感动你!

相关电脑知识

美图欣赏

电脑知识排行榜