您好我需要设置时间选择器的对话框并返回用户声明的结果。
现在我有了那段代码
.
.
.
showDialog(0);
.
.
.
@Override
protected Dialog onCreateDialog(int id) {
return new TimePickerDialog(this, mTimeSetListener, hour, minute,
false);
}
该代码设置了时间选择器的对话框,但我还没有找到返回结果的方法。
答案 0 :(得分:1)
int StartHour;
int StartMinute;
TimePickerDialog.OnTimeSetListener mTimeSetListenerStart = new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minutex) {
// TODO Auto-generated method stub
StartHour = hourOfDay;
StartMinute = minutex;
Log.d("TimeStart", StartHour+" "+StartMinute);
} };
答案 1 :(得分:0)
protected Dialog onCreateDialog(int id) {
if (id == DIALOG_TIME) {
TimePickerDialog tpd = new TimePickerDialog(this, myCallBack, myHour, myMinute, true);
return tpd;
}
return super.onCreateDialog(id);
}
OnTimeSetListener myCallBack = new OnTimeSetListener() {
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
myHour = hourOfDay;
myMinute = minute;
tvTime.setText("Time is " + myHour + " hours " + myMinute + " minutes");
}
};