DatePicker

Additional

Language
Java
Version
N/A
Created
Dec 21, 2011
Updated
Feb 4, 2014 (Retired)
Owner
Bhavesh Hirpara (bhavesh-hirpara)
Contributor
Bhavesh Hirpara (bhavesh-hirpara)
1
Activity
Badge
Generate
Download
Source code

Announcement

@Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  DatePicker d = (DatePicker) findViewById(R.id.datePicker1);
  d.setDateChangedListener(this);

  try {
   d.setStartYear(2000);
   d.setEndYear(2009);
  } catch (Exception e) {
   Log.e("", e.toString());
  }

  TimePicker t = (TimePicker) findViewById(R.id.timePicker2);
  t.setTimeChangedListener(this);
  t.setCurrentTimeFormate(TimePicker.HOUR_12);
  t.setAMPMVisible(true);
 }

 @Override
 public void onDateChanged(Calendar c) {
  Log.e("",
    "" + c.get(Calendar.MONTH) + " " + c.get(Calendar.DAY_OF_MONTH)
      + " " + c.get(Calendar.YEAR));
 }

 @Override
 public void onTimeChanged(int h, int m, int am_pm) {
  Log.e("", "" + h + " " + m + " " + am_pm);
 }