0

您好我需要设置一个时间选择器的对话框并返回用户声明的结果。

现在我有那个代码

.
.
.
showDialog(0);
.
.
.

@Override
    protected Dialog onCreateDialog(int id) {

              return  new TimePickerDialog(this, mTimeSetListener, hour, minute,
                        false);

    }

该代码设置了时间选择器的对话框,但我还没有找到返回结果的方法。

4

2 回答 2

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);
            } };
于 2012-08-09T14:37:33.107 回答
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");
}

};

于 2012-08-09T14:23:36.753 回答