2014-12-03 17 views
10

Spojrzałem na this answer, ale za pomocą API timepickerdialog (kod poniżej) Chciałbym ustawić właściwość timePickerMode w mojej klasie. Czy to możliwe?Android - Jak programowo zmienić tryb timepicker?

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 
    } 
} 
+0

@DerGolem the timePickerMode, (może to być _clock_ lub _spinner_) – SNinja

+0

Nie jest obecnie możliwe w czasie wykonywania, czy mógłbyś zgłosić żądanie funkcji na https://code.google. com/p/android/issues/list /? – alanv

Odpowiedz

2

Mam ten sam problem. Następnie czytałem kod źródłowy TimePicker. Myślę, że nie możemy zmienić trybu timepikera w pliku .java. Tryb ustawiania Google TimePicker w metodzie contructor: http://prntscr.com/blkkkd

+0

Witam, jeśli tak jest, można po wywołaniu super konstruktora zmienić obiekt mDelgate za pomocą odbicia. –