I had a look at this answer but using the APIs timepickerdialog (code below) I would like to set timePickerMode property in my class .java is it possible?
    public static 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
    }
}
                TimePickerDialog timePickerDialog = new TimePickerDialog(MainActivity. this, new TimePickerDialog. OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int hourOfDay, int minutes) { } }, 0, 0, false); 9- Finally add the following code to be able to see TimePickerDialog appear in the screen.
I have the same issue. Then I read TimePicker source code. I think we can't change timepicker mode in .java file. Google set mode of TimePicker in contructor method: http://prntscr.com/blkkkd
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