在Android L Dev预览中,TimePickerDialog包含一个“完成”按钮,与“正面按钮”相同。这是Android Lolipop中拾取器的默认行为还是只是预览错误? 有没有办法删除它? 这是创建对话框的代码:
DialogFragment timePickerFragment = new DialogFragment()
{
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
TimePickerDialog.OnTimeSetListener listener = new TimePickerDialog.OnTimeSetListener()
{
@Override
public void onTimeSet(TimePicker timePicker, int hours, int minutes)
{
DoStuff(hours * TimeUtils.HOUR_MINUTES + minutes);
}
};
TimePickerDialog dialog = new TimePickerDialog(getActivity(), AlertDialog.THEME_HOLO_LIGHT, listener, 0, 0, true);
dialog.setButton(TimePickerDialog.BUTTON_POSITIVE, "OK", dialog);
dialog.setButton(TimePickerDialog.BUTTON_NEGATIVE, "Cancel", dialog);
dialog.setTitle("Set time");
return dialog;
}
};
timePickerFragment.show(getActivity().getSupportFragmentManager(), "time_picker");
KitKat中的结果(如预期的那样):
Lolipop的结果(带“完成”按钮)