How to show the old android timePicker ? the one that appears only the numbers

Asked

Viewed 146 times

0

I’m using a code from the own documentation of android to create the timepicker as dialog, but it is appearing like this

inserir a descrição da imagem aqui

And I want him to show up like this

inserir a descrição da imagem aqui

Class that creates timepicker

public class TimePickerFragment extends DialogFragment
    implements TimePickerDialog.OnTimeSetListener {

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current time as the default values for the picker
    final Calendar c = Calendar.getInstance();
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);

    // Create a new instance of TimePickerDialog and return it
    return new TimePickerDialog(getActivity(), this, hour, minute,
            DateFormat.is24HourFormat(getActivity()));
}

public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
    // Do something with the time chosen by the user
}
}

CODE THAT INVOKES THE TIMEPICKER BY CLICKING THE BUTTON

    public void showTimePickerDialog(View v) {
    DialogFragment newFragment = new TimePickerFragment();
    newFragment.show(getSupportFragmentManager(), "timePicker");
}

1 answer

2


In the onCreateDialog(), of Timepickerfragment, return the Timepickerdialog created this way:

return new TimePickerDialog(getActivity(), AlertDialog.THEME_HOLO_DARK, this, hour, minute,
                            DateFormat.is24HourFormat(getActivity()));

If you are using Timepicker use the attribute android:timePickerMode

Clock:

android:timePickerMode="clock"

Spinner:

android:timePickerMode="spinner"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.