【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;



禁止转载

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。