How to set the timepicker "timePickerMode" attribute to "spinner" via java?

Asked

Viewed 55 times

0

class that creates the 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
}
}

method that calls the timepicker by clicking the button

    public void showTimePickerDialog(View v) {
    DialogFragment newFragment = new TimePickerFragment();
    newFragment.show(getSupportFragmentManager(), "timePicker");
}
  • See if it resolves: http://stackoverflow.com/a/35203223/2570426

  • Not really that, but I see the help

  • I did not find anything that solves this there not! I will take another look here.

  • Look at this other reply I’ve already given to you.

  • This answer is to do this with XML, I’m asking how to do the same thing through java code

No answers

Browser other questions tagged

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