Search code examples
androidandroid-jetpackandroid-jetpack-compose

Jetpack compose. Date time picker


Does the jetpack compose have the date time picker view or I should create it by myself? I have tried to google it but I couldn't find ready to use component.


Solution

  • Using a library

    As of writing, It's not implemented yet. But there is an open-source library Compose Material Dialogs

    Date and Time Picker

    Without a library

    You can Also do this without a library, you can put it inside onclick action

    private fun showDatePicker() {
        val picker = MaterialDatePicker.Builder.datePicker().build()
        activity?.let {
            picker.show(it.supportFragmentManager, picker.toString())
            picker.addOnPositiveButtonClickListener {
    
            }
        }
    }
    

    The old way :D