'a geçtikten sonra güncellenmiyor. Örneğin, bu saati oluşturduğumda (aşağıda) saat 18: 00'de, timePicker'ın timeValue'si saat 06: 00'da olacaktır. Saat 19: 44-> 07:44 ... Bu yüzden AM/PM'den 24h moduna geçildikten sonra doğru saatte hareket etmiyor. Bunu nasıl değiştirebilirim? Amacım, timePicker öğesinin oluşturulduğu zamanı göstermesidir. AM/PM modunda kullandığımda olduğu gibi.TimePicker saati, 24 saat
TimePicker timePicker = (TimePicker) convertView.findViewById(R.id.time_picker);
timePicker.setIs24HourView(true);
Kötü formülasyonu için ağlayın, umarım sorumu anlayabilirsiniz. Aksi takdirde sadece sor.
GÜNCELLEME:
public class ChooseTimeViewDialog extends AlertDialog {
protected Context context;
public ChooseTimeViewDialog(final Context context) {
super(context);
this.context = context;
}
public void onCreate(Bundle savedInstanceState) {
LayoutInflater inflater = this.getLayoutInflater();
View convertView = inflater.inflate(R.layout.dialog_choose_time_view, null);
setContentView(convertView);
setTitle(R.string.title_dialog_choose_time_view);
final TimePicker taskTimePicker = (TimePicker) convertView.findViewById(R.id.dctv_task_time_picker);
taskTimePicker.setIs24HourView(true);
setButton(DialogInterface.BUTTON_POSITIVE, "Choose", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int hour = taskTimePicker.getCurrentHour();
int minute = taskTimePicker.getCurrentMinute();
Calendar cal = new GregorianCalendar();
cal.set(0, 0, 0, hour, minute, 0);
((AddTaskViewActivity) context).setSelectedTime(cal.getTime());
}
});
setButton(DialogInterface.BUTTON_NEUTRAL, "No time", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
((AddTaskViewActivity) context).setSelectedTime(null);
}
});
}
}
XML: Ben onCreate için initialiation taşındı ve setContentView (Görünüm) kullandıktan sonra
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TimePicker
android:id="@+id/dctv_task_time_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
, diyalog arka plan, şeffaf o tam ekran ve hiçbir vardır buttons..why?
Eh bunu düzeltmek olabilir, ama aslında değil bir güzel çözüm, daha iyi? timePicker.setCurrentHour (new Date() getHours().); – StupidBird
Bu kod ne zaman çalıştırılır? Birçok widget, oluşturulduktan sonra sihirli bir şekilde yeniden çizilmez. – rds
Yaptığım SelectTimeDialog adlı özel bir AlertDialog kurucusunda yürütülür. İletişim kutusunu her açtığımda yeni bir nesne yaratıyorum: yeni SelectTimeDialog (this) .show(); – StupidBird