how to pick a time using material:1.3.0-alpha01, I am looking time picker following screenshot, which I found in material io.
I tried date picker is working
Material Date picker
//Creating a MaterialDatePicker.Builder instance that gives us a single date selector.
val builder : MaterialDatePicker.Builder<*> = MaterialDatePicker.Builder.datePicker() // 1
//Building-up the MaterialDatePicker by calling a builder.build function
val picker : MaterialDatePicker<*> = builder.build() // 2
//Display the Material Date Picker.
picker.show(requireActivity().supportFragmentManager, picker.toString()) // 3
Simple Time picker
val cal = Calendar.getInstance()
val timeSetListener = TimePickerDialog.OnTimeSetListener { _, hour, minute ->
cal.set(Calendar.HOUR_OF_DAY, hour)
cal.set(Calendar.MINUTE, minute)
//textView.text = SimpleDateFormat("HH:mm").format(cal.time)
}
val time = TimePickerDialog(context, timeSetListener, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), true)
time.setTitle("")
time.show()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…