Shadow
Shadow

Reputation: 6899

How to use TimePicker with keyboard input android?

I am using TimePicker but keyboard input in TimePicker works from Android 6 to Android 7.

After Android 8, keyboard input in TimePicker is not working. When I checked in aosp source code, keyboard input functions been totally removed.

Let me know is it possible to implement keyboard input in TimePicker without using MaterialTimePicker?

Because I cross checked that MaterialTimePicker is working when I use the below code:

   MaterialTimePicker materialTimePicker = new MaterialTimePicker.Builder()
                        .setInputMode(INPUT_MODE_KEYBOARD)
                        .setTimeFormat(android.text.format.DateFormat.is24HourFormat(MainActivity.this)?TimeFormat.CLOCK_24H:TimeFormat.CLOCK_12H)
                        .setHour((!android.text.format.DateFormat.is24HourFormat(MainActivity.this) && Calendar.getInstance().getTime().getHours()>12)?Calendar.getInstance().getTime().getHours() - 12:Calendar.getInstance().getTime().getHours())
                        .setMinute(Calendar.getInstance().getTime().getMinutes())
                        .build();

                materialTimePicker.show(getSupportFragmentManager(), "fragment_tag");

But I want to use TimePicker (without using MaterialTimePicker) from android's sdk import statement.

My 2 questions are:

  1. Why android removed keyboard function from Android 8 in Android's TimePicker?
  2. Is it possible to use without using MaterialTimePicker

Upvotes: 1

Views: 370

Answers (0)

Related Questions