我创建了一个TimePickerDialog
,在我的对话框的顶部,我看到了我设置的时间。我看到HH:mm AM但是我不想看到" AM"。我没有设置标题,我也不知道如何覆盖这个标题。我怎么能这样做?
public static class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener{
private TimePickerDialog timepic;
private Calendar dateLimit;
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
Calendar calendar = new GregorianCalendar();
calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
calendar.set(Calendar.MINUTE, minute);
if (flag == 0) {
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
startDate = calendar.getTime();
// if (endDate.getTime() < startDate.getTime())
// tvEndDate.setText("");
// tvStartDate.setText(simpleDateFormat.format(startDate));
} else if (flag == 1) {
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 0);
endDate = calendar.getTime();
// if (endDate.getTime() >= startDate.getTime())
// tvEndDate.setText(simpleDateFormat.format(endDate));
// else
// Toast.makeText(getActivity().getApplicationContext(), "Data końcowa musi być większa od daty początkowej", Toast.LENGTH_LONG).show();
}
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Calendar c = Calendar.getInstance();
if (flag == 0) {
c = DateToCalendar(startDate);
} else if (flag == 1) {
c = DateToCalendar(endDate);
}
timepic = new TimePickerDialog(getActivity(), this, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE), true);
return timepic;
}
}
答案 0 :(得分:0)
TimePickerDialog是AlertDialog的子类。这意味着您可以在调用setTitle(CharSequence text)
时直接使用onTimeSet
方法。