我查看了this answer但是使用了API timepickerdialog(下面的代码)我想在我的类.java中设置timePickerMode属性是否可能?
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 :(得分:2)
我有同样的问题。然后我读了TimePicker源代码。我想我们无法在.java文件中更改timepicker模式。 Google在构造方法中设置了TimePicker模式:http://prntscr.com/blkkkd