내 TimePickerDialog에 문제가 있습니다.android에서 12 또는 24 시간 형식의 TimePicker 표시
…
if(format.equals("24"){
view.setIs24HourView(true);
} else {
view.setIs24HourView(true);
} …
:
이
…
String format;
…
if (DateFormat.is24HourFormat(this)) {
Log.i("control","Format 24");
format=("24");
} else {
Log.i("control","Format 12");
format=("12");
}
…
이제 내 의도는 형식에 따라 오전 또는 오후의 옵션을 사용하여 TimePicker를 보여주는 것입니다 : 사용자의 장치가 12 또는 24 시간 형식으로 시간을 경우 첫 검출
이는 전체 코드 TimePickerDialog는 다음과 같습니다
public class AlarmPreferencesActivity extends ListActivity
…
TimePickerDialog timePickerDialog = new TimePickerDialogs(this, new TimePickerDialog.OnTimeSetListener(){
@Override
public void onTimeSet(TimePicker view, int hours, int minutes) {
Calendar newAlarmTime = Calendar.getInstance();
newAlarmTime.set(Calendar.HOUR_OF_DAY, hours);
newAlarmTime.set(Calendar.MINUTE, minutes);
newAlarmTime.set(Calendar.SECOND, 0);
alarm.setAlarmTime(newAlarmTime);
alarmPreferenceListAdapter
.setMathAlarm(getMathAlarm());
alarmPreferenceListAdapter
.notifyDataSetChanged();
}},
alarm.getAlarmTime().get(Calendar.HOUR_OF_DAY),
alarm.getAlarmTime().get(Calendar.MINUTE), true);
timePickerDialog.setCancelable(true);
timePickerDialog.setCustomTitle(getLayoutInflater().inflate(R.layout.custom_hours, null));
timePickerDialog.show();
}
내 문제는 내가 view.setIs24HourView (true)
또는 (false)
를 포함하는 곳 몰라. 많은 변형을 시도했지만 아무런 효과가 없습니다. 정보는 찾았지만 성공하지 못했습니다.
사용중인 TimePickerDialog 생성자에 대한 설명서를 읽었습니까? – njzk2