码迷,mamicode.com
首页 > 移动开发 > 详细

Android 时间控件修改生日

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

标签:android   io   for   ar   cti   log   时间   new   

 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 时间控件修改生日

标签:android   io   for   ar   cti   log   时间   new   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!