如何删除"完成" Android L中来自AlertDialog的按钮?

时间:2014-10-20 10:19:59

标签: android android-5.0-lollipop

在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中的结果(如预期的那样): Result in KitKat (as expected)

Lolipop的结果(带“完成”按钮) Result in Lolipop (with "Done" button)

0 个答案:

没有答案