У меня есть хронометр в 24-часовом формате. Теперь я хочу отображать текущее время устройства в 24-часовом формате независимо от формата времени устройства. Прямо сейчас мое устройство находится в 12-часовом формате, поэтому, например, мое время 14:04, хронометр должен быть 14:04.
Вот мой код или таймпикер. Он находится в другом макете, потому что я показываю их в диалоговом окне.
XML:
<LinearLayout android:id="@+id/datetimepickerLayout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" xmlns:android="http://schemas.android.com/apk/res/android">
<DatePicker android:id="@+id/datePicker1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center"></DatePicker>
<TimePicker android:id="@+id/timePicker1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center"></TimePicker>
<Button
android:id="@+id/setdatetimeBtn1"
android:text="Set"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_gravity="center"/>
Now in my java code:
timePicker1 = (TimePicker)dialog.findViewById(R.id.timePicker1);
datePicker1 = (DatePicker)dialog.findViewById(R.id.datePicker1);
setDateTimeBtn1 = (Button)dialog.findViewById(R.id.setdatetimeBtn1);
datePicker1.setCalendarViewShown(false);
timePicker1.setIs24HourView(true);
Есть идеи? Спасибо!