本文整理汇总了Java中android.text.format.DateUtils.FORMAT_24HOUR属性的典型用法代码示例。如果您正苦于以下问题:Java DateUtils.FORMAT_24HOUR属性的具体用法?Java DateUtils.FORMAT_24HOUR怎么用?Java DateUtils.FORMAT_24HOUR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.text.format.DateUtils
的用法示例。
在下文中一共展示了DateUtils.FORMAT_24HOUR属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatchPopulateAccessibilityEvent
/**
* Announce the currently-selected time when launched.
*/
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
// Clear the event's current text so that only the current time will be spoken.
event.getText().clear();
Time time = new Time();
time.hour = getHours();
time.minute = getMinutes();
long millis = time.normalize(true);
int flags = DateUtils.FORMAT_SHOW_TIME;
if (mIs24HourMode) {
flags |= DateUtils.FORMAT_24HOUR;
}
String timeString = DateUtils.formatDateTime(getContext(), millis, flags);
event.getText().add(timeString);
return true;
}
return super.dispatchPopulateAccessibilityEvent(event);
}
示例2: dispatchPopulateAccessibilityEvent
/**
* Announce the currently-selected time when launched.
*/
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
// Clear the event's current text so that only the current time will be spoken.
event.getText().clear();
Calendar time = Calendar.getInstance();
time.set(Calendar.HOUR, getHours());
time.set(Calendar.MINUTE, getMinutes());
time.set(Calendar.SECOND, getSeconds());
long millis = time.getTimeInMillis();
int flags = DateUtils.FORMAT_SHOW_TIME;
if (mIs24HourMode) {
flags |= DateUtils.FORMAT_24HOUR;
}
String timeString = DateUtils.formatDateTime(getContext(), millis, flags);
event.getText().add(timeString);
return true;
}
return super.dispatchPopulateAccessibilityEvent(event);
}
示例3: onPopulateAccessibilityEvent
@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
int flags = DateUtils.FORMAT_SHOW_TIME;
if (mIs24Hour) {
flags |= DateUtils.FORMAT_24HOUR;
} else {
flags |= DateUtils.FORMAT_12HOUR;
}
mTempCalendar.set(Calendar.HOUR_OF_DAY, getHour());
mTempCalendar.set(Calendar.MINUTE, getMinute());
final String selectedTime = DateUtils.formatDateTime(mContext,
mTempCalendar.getTimeInMillis(), flags);
final String selectionMode = mRadialTimePickerView.getCurrentItemShowing() == HOUR_INDEX ?
mSelectHours : mSelectMinutes;
event.getText().add(selectedTime + " " + selectionMode);
}
示例4: onPopulateAccessibilityEvent
@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
int flags = DateUtils.FORMAT_SHOW_TIME;
if (mIs24HourView) {
flags |= DateUtils.FORMAT_24HOUR;
} else {
flags |= DateUtils.FORMAT_12HOUR;
}
mTempCalendar.set(Calendar.HOUR_OF_DAY, getHour());
mTempCalendar.set(Calendar.MINUTE, getMinute());
String selectedDateUtterance = DateUtils.formatDateTime(mContext,
mTempCalendar.getTimeInMillis(), flags);
event.getText().add(selectedDateUtterance);
}