0
我使用我的應用程序時選擇器對話,所以這個問題很簡單,我想在格式上午07:00時。這是我的代碼,我得到的輸出爲上午7:00。 在此先感謝...如何更改android時間選擇器對話框輸出?
private TimePickerDialog.OnTimeSetListener TimePickerListener = new TimePickerDialog.OnTimeSetListener() {
// while dialog box is closed, below method is called.
public void onTimeSet(TimePicker view, int hour, int minute) {
mCalen.set(Calendar.HOUR_OF_DAY, hour);
mCalen.set(Calendar.MINUTE, minute);
int hour12format = mCalen.get(Calendar.HOUR);
hourOfDay = mCalen.get(Calendar.HOUR_OF_DAY);
minute = mCalen.get(Calendar.MINUTE);
ampm = mCalen.get(Calendar.AM_PM);
String ampmStr = (ampm == 0) ? "AM" : "PM";
// Set the Time String in Button
if(flag==111)
from.setText(hour12format + ":" + minute + " "+ ampmStr);
else if(flag==222)
to.setText(hour12format + ":" + minute + " "+ ampmStr);
}
};