In my project, I use TimepickerDialog
to show the time in a TextView
. My Timepickerdialog
is shown as a clock, but I want it shown as a spinner. How can I do this?
use this code show time picker as spinner
public void showCustomTimePicker()
{
final Calendar myCalender = Calendar.getInstance();
int hour = myCalender.get(Calendar.HOUR_OF_DAY);
int minute = myCalender.get(Calendar.MINUTE);
TimePickerDialog.OnTimeSetListener myTimeListener = new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
if (view.isShown()) {
myCalender.set(Calendar.HOUR_OF_DAY, hourOfDay);
myCalender.set(Calendar.MINUTE, minute);
}
}
};
TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(), android.R.style.Theme_Holo_Light_Dialog_NoActionBar, myTimeListener, hour, minute, true);
timePickerDialog.setTitle("Choose hour:");
timePickerDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
timePickerDialog.show();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With