I want TimePickerDialog to be in spinner mode

Asked 2 years ago, Updated 2 years ago, 36 views

If you call TimePickerDialog from java, you will be in clock mode, so I would like to know how to call it in spinner mode.

Calendar calendar=Calendar.getInstance();
    int hour = calendar.get(Calendar.HOUR_OF_DAY);
    int minute = calendar.get (Calendar.MINUTE);

    TimePickerDialog timeDialog = new TimePickerDialog(this,
            newTimePickerDialog.OnTimeSetListener(){
                @ Override
                public void onTimeSet(TimePicker timePicker, inth, intm) {
                    String time = String.format ("%02d hour %02d minute", h, m);
                    TextView end= (TextView) findViewById (R.id.endTime);
                    end.setText(time);
                }
            }, hour, minute, true);
    timeDialog.show();

android java

2022-09-30 18:11

1 Answers

TimePickerDialog timeDialog = newTimePickerDialog(this,
        AlertDialog.THEME_HOLO_LIGHT,
        newTimePickerDialog.OnTimeSetListener(){
            @ Override
            public void onTimeSet(TimePicker timePicker, inth, intm) {
                String time = String.format ("%02d hour %02d minute", h, m);
                TextView end= (TextView) findViewById (R.id.endTime);
                end.setText(time);
            }
        }, hour, minute, true);
timeDialog.show();

If you set the HOLO theme for the second constructor argument like this, you will become a spinner.I think it's deprecated because it's old.


2022-09-30 18:11

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.