In This Example We See Get Data From Time Picker And Date Picker One by One.
TimePickerDialog timePickerDialog; int hour1,minutes1; int cYear,cMonth,cDay;editText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar getDate = Calendar.getInstance(); cDay = getDate.get(Calendar.DAY_OF_MONTH); cMonth = getDate.get(Calendar.MONTH); cYear = getDate.get(Calendar.YEAR); timePickerDialog = new TimePickerDialog(DesignActivity.this, new TimePickerDialog. OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { final String AM_PM ; if (hourOfDay > 12) { hourOfDay -= 12; AM_PM = "pm"; } else if (hourOfDay == 0) { hourOfDay += 12; AM_PM = "am"; } else if (hourOfDay == 12) AM_PM = "pm"; else AM_PM = "am"; hour1 = hourOfDay; minutes1 = minute; DatePickerDialog datePicker =new DatePickerDialog(DesignActivity.this, new DatePickerDialog. OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) { cYear = year; cMonth = month; cDay = dayOfMonth; editText.setText(hour1 + ":" +minutes1 + AM_PM + " " + cDay + "/" + cMonth + "/" + cYear); } },cYear,cMonth,cDay); datePicker.show(); } },hour1,minutes1,false); timePickerDialog.show(); } });
No comments:
Post a Comment