Challenge: TimeDialoge

This method is without a new fragment… it shows time picker dialog directly…

I created a button on the view…

        android:text="12:34 PM"/>

defined it in CrimeFragment and added a listener to open the dialog…

crimeTime.setOnClickListener {
            val calendar = Calendar.getInstance()
            val timeListener = TimePickerDialog.OnTimeSetListener { timePicker: TimePicker , hourOfDay, minute ->
                calendar.set(Calendar.HOUR_OF_DAY, hourOfDay)
                calendar.set(Calendar.MINUTE, minute)
                crimeTime.text = java.text.SimpleDateFormat("HH:mm").format(calendar.time)
            TimePickerDialog(context, timeListener, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), false).show()

there you go…