I want to use the digital date picker dialog and time picker dialog, I have written the code and my picker dialogs are working, but I want them in another format.
Currently, my time picker and date picker dialog are in this format:
I want them like this:
Here is my code:
public void onClick(View v) {
int id = v.getId();
switch (id) {
case R.id.linearDate: {
DatePickerDialog dp = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
mDatetext.setText(dayOfMonth + "-" + monthOfYear + "-" + year);
}
}, year, month, day);
dp.show();
break;
}
case R.id.linearTime: {
TimePickerDialog Tp = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
mTimetext.setText(hourOfDay + ":" + minute);
}
}, hour, min, false);
Tp.show();
break;
}
case R.id.linearPlace: {
startActivityForResult(new Intent(this, Location.class), CITY);
break;
}
}
}
It's very simple and I got my code working. I need to add theme and it's done.
case R.id.linearDate: {
DatePickerDialog dp = new DatePickerDialog(this,
android.R.style.Theme_Holo_Light_Dialog,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
mDatetext.setText(dayOfMonth + "-" + monthOfYear + "-" + year);
}
},
year, month, day);
dp.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dp.show();
break;
}
case R.id.linearTime: {
TimePickerDialog Tp = new TimePickerDialog(this,
android.R.style.Theme_Holo_Light_Dialog,
new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
mTimetext.setText(hourOfDay + ":" + minute);
}
},
hour, min, false);
Tp.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
Tp.show();
break;
}