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;
禁止转载
原文地址:http://blog.csdn.net/fried_potatoes/article/details/44968741