public void registerButtonListener() {
mData.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
showDialog(2);
// showDatePicker();
}
});
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case 2:
return showTimePicker();
}
//return super.onCreateDialog(id);
return dialog;
} //kraj na dialogot
private TimePickerDialog showTimePicker() {
TimePickerDialog timePicker = new TimePickerDialog(
this,
new TimePickerDialog.OnTimeSetListener() {
// @Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
mCalendar.set(Calendar.HOUR_OF_DAY,hourOfDay);
mCalendar.set(Calendar.MINUTE,minute);
updateTimeButtonText();
}
},
mCalendar.get(Calendar.HOUR_OF_DAY),
mCalendar.get(Calendar.MINUTE),true);
return timePicker;
}
我没有得到任何选择器,我在另一个示例中使用了教程中的代码并且它有效。我的错误是什么?
答案 0 :(得分:0)
您可能尚未启动日历,在您的情况下放入onCreate()
mCalendar=Calendar.getInstance()
,这可能会解决您的错误。