티스토리 뷰



안드로이드/Andoird DatePiker 사용하기
 

/**
	 * DataPiker 년/월/일
	 */
	private void DialogDatePicker(){
		Calendar c = Calendar.getInstance();
		int cyear = c.get(Calendar.YEAR);
		int cmonth = c.get(Calendar.MONTH);
		int cday = c.get(Calendar.DAY_OF_MONTH);

		DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
			// onDateSet method
			public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
				String date_selected = String.valueOf(monthOfYear+1)+
				" /"+String.valueOf(dayOfMonth)+" /"+String.valueOf(year);
				Toast.makeText( BSMeasureActivity.this, 
						"Selected Date is ="+date_selected, Toast.LENGTH_SHORT).show();
			}
		};
		DatePickerDialog alert = new DatePickerDialog(this,  mDateSetListener,  
				cyear, cmonth, cday);
		alert.show();
	}


아래는 DataPiker 메서드의 실행 화면 입니다.
 







댓글
댓글쓰기 폼