Android – 如何以编程方式更改时间戳模式?

前端之家收集整理的这篇文章主要介绍了Android – 如何以编程方式更改时间戳模式?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我看了一下 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
原文链接:/android/312110.html

猜你在找的Android相关文章