0

I just want this Current situation to Target situation

For more detail, I wanna make timepickerdialog to spinner mode. In my app, it not worked. This is my code:

  public class TimePickerFragment extends DialogFragment {
  ...
  @Override
  public Dialog onCreateDialog (Bundle savedInstanceState) {

    Calendar cal = DateUtils.getCalendar(defaultTime);
    int hour = cal.get(Calendar.HOUR_OF_DAY);
    int minute = cal.get(Calendar.MINUTE);

    // Create a new instance of TimePickerDialog and return it
    boolean is24HourMode = DateUtils.is24HourMode(mActivity);
    TimePickerDialog tpd = new TimePickerDialog(mActivity, R.style.Theme_AppCompat_Dialog_NoBackgroundOrDim, mListener,
        hour, minute, is24HourMode);
    tpd.getWindow().setGravity(Gravity.BOTTOM);
    tpd.setTitle("");
    return tpd;
  }
}

2 Answers2

1

You can set the time picker mode using xml attribute in your layout: timePickerMode="spinner"

<TimePicker
    android:id="@+id/timePicker"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:timePickerMode="spinner">
</TimePicker>

If you want to set it using code it's little tricky:

Either follow this: https://stackoverflow.com/a/27264558/1881240

or this: https://prnt.sc/blkkkd

0

I finished by apply AlertDialog.Theme_Holo_Dark. It works for me that using android sdk 29.