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