我遇到一个奇怪的问题,即TimePickerDialog的onClick()侦听器已停止在Android 8.0上运行。
这是我的代码:
_timePickerDialog.setButton(DialogInterface.BUTTON_POSITIVE,"SET", new DialogInterface.OnClickListener() {
//System.out.println("ZZZZZ HIT!!!! onClick for _showTimeDialog ");
public void onClick(DialogInterface arg0, int arg1) {
_done = true;
/*
* HACK: TimePickerDialog does not have a public method to return
* the TimePicker hence we get a handle to the TimePicker from the
* sdk. This would not work if the id of that component changes.
*/
System.out.println("ZZZZZ HIT!!!! onClick for _showTimeDialog ");
int searchPlateId = _timePickerDialog.getContext().getResources().getIdentifier("android:id/timePicker", null, null);
TimePicker searchPlate = (TimePicker) _timePickerDialog.findViewById(searchPlateId);
//String android_os = getAndroidVersion(android.os.Build.VERSION.SDK_INT);
// if(android.os.Build.VERSION.SDK_INT > 23)
_timePickerDialogCallback.onTimeSet(searchPlate, searchPlate.getHour(), searchPlate.getMinute());
// else
// _timePickerDialogCallback.onTimeSet(searchPlate, searchPlate.getCurrentHour(), searchPlate.getCurrentMinute());
//_timePickerDialogCallback.onTimeSet(searchPlate, searchPlate.getHour(), searchPlate.getMinute());
//_timePickerDialogCallback.onTimeSet(searchPlate, searchPlate.getCurrentHour(), searchPlate.getCurrentMinute());
System.out.println("ZZZZZ END HIT!!!! onClick for _showTimeDialog ");
}
});
当我使用DialogInterface.BUTTON_NEUTRAL或DialogInterface.BUTTON_NEGATIVE按钮进行连接时,相同的代码也起作用。
这也适用于旧版Android。
我正在观察的问题是,单击“确定”按钮没有击中onClick()方法。
请告知。