1
試圖找出android中的timepicker對話框。 我遇到的問題是,當我選擇一個時間,並把它放在我的TextView字段中,所有前面的零都被刪除。顯示爲6:5。 如何保留前面的零?Android時間選擇器對話框不返回零前
我timepicker的代碼:
ic_BedtimePicker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Calendar mcurrentTime = Calendar.getInstance();
int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
int minute = mcurrentTime.get(Calendar.MINUTE);
TimePickerDialog mTimePicker;
mTimePicker = new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
editBedtime.setText("" + selectedHour + ":" + selectedMinute);
}
}, hour, minute, true);
mTimePicker.setTitle("Select Time");
mTimePicker.show();
}
});