Reputation: 27
I saw from the documentation, there explained that we could change the input mode, for example the script:
builder.setInputMode (MaterialDatePicker.INPUT_MODE_TEXT);
So, how can I change the input mode using the TimePickerDialog class?
Basically I want to make the default as shown below:
I use fragments when calling TimePickerDialog, like this:
@SuppressLint("DefaultLocale") TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(),
(view13, hourOfDay, minute1) -> {
String time = String.format("%02d:%02d", hourOfDay, minute1);
viewModel.setTimeIn(time);
},
Integer.parseInt(hour), Integer.parseInt(minute), false);
timePickerDialog.show();
Upvotes: 1
Views: 1351
Reputation: 364858
It is related to the new MaterialTimePicker
included in the Material Components Library.
val materialTimePicker = MaterialTimePicker.Builder()
.setInputMode(MaterialTimePicker.INPUT_MODE_KEYBOARD)
.build()
materialTimePicker.show(supportFragmentManager, "fragment_tag")
Note: this code requires at least the version 1.3.0-alpha03
.
Upvotes: 1