6
:TimePickerDialog.onTimeSetListener我用下面的代碼顯示<code>TimePickerDialog</code>不叫
TimePickerDialog dialog = new TimePickerDialog(this, new OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
System.out.println("onTimeSet");
}
}, 20, 15, true);
dialog.setTitle("Test");
dialog.setButton(TimePickerDialog.BUTTON_POSITIVE, "Done", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
System.out.println("Done");
}
});
dialog.setButton(TimePickerDialog.BUTTON_NEGATIVE, "Cancel", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
System.out.println("Cancel");
}
});
dialog.show();
在運行Android 2.3.7的設備時,onTimeSet
方法不會被調用(在onClick
方法做) 。在運行4.2.2的設備上,onTimeSet
確實會被調用。
這裏發生了什麼?