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

【android】时间选择器

时间:2015-04-10 09:37:25      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:安卓   android   

OnDateSetListener listener = new OnDateSetListener() {

		@Override
		public void onDateSet(DatePicker arg0, int arg1, int arg2, int arg3) {
			// TODO Auto-generated method stub
			String str = null;
			String str1 = null;
			if (arg2 < 10) {
				arg2 = arg2 + 1;
				str = "0" + arg2;
			} else {
				str = arg2 + "";
			}
			if (arg3 < 10) {
				str1 = "0" + arg3;
			} else {
				str1 = arg3 + "";
			}

			t4.setText(arg1 + "-" + str + "-" + str1);
		}
	};



		case R.id.textView4:
			Calendar c1 = Calendar.getInstance();
			int year = c1.get(Calendar.YEAR);
			int monthOfYear = c1.get(Calendar.MONTH);
			int dayOfMonth = c1.get(Calendar.DAY_OF_MONTH);

			DatePickerDialog dialog = new DatePickerDialog(ToRecordActivit.this,
					listener, year, monthOfYear, dayOfMonth);
			dialog.show();
			break;



禁止转载

【android】时间选择器

标签:安卓   android   

原文地址:http://blog.csdn.net/fried_potatoes/article/details/44968741

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