本文整理匯總了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);
}