首页 > 移动平台 > 详细

Android 时间控件修改生日

时间:2014-08-20 10:24:46      阅读:549      评论:0      收藏:0      [点我收藏+]

 private class TextView_persinal_birth_onClick implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            DatePickerDialog.OnDateSetListener dateSetListener=new DatePickerDialog.OnDateSetListener() {
                @Override
                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);
                    try {
                        Date date_input=simpleDateFormat.parse(simpleDateFormat.format(calendar.getTime()));
                        Date date_system=simpleDateFormat.parse(simpleDateFormat.format(Calendar.getInstance().getTime()));
                        long inputTime=date_input.getTime();
                        long systemTime=date_system.getTime();
                        if (inputTime<=systemTime){
                            birth=simpleDateFormat.format(calendar.getTime());
                            textView_persional_birth.setText(birth);
                        }
                        else
                            Toast.makeText(PersonalInformationActivity.this,"生日不能大于当前日期!",1).show();

                    } catch (ParseException e) {
                        e.printStackTrace();
                    }


                }
            };
            new DatePickerDialog(PersonalInformationActivity.this,
                dateSetListener,
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH)).show();
        }
    }

Android 时间控件修改生日,布布扣,bubuko.com

Android 时间控件修改生日

原文:http://www.cnblogs.com/chenxinwen/p/3923932.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!