Search code examples
androidkotlinandroid-viewbinding

How to edit the text of a textView using viewbinding?


I am new to kotlin and android and I just started getting into using viewbindings. Im trying to make this locations app and when setting the date through a datepickerdialog, when i try to edit the text of a textview with a binding its giving me errors. Can someone help me?

private fun displaySelectedDate(timestamp : Long){

    binding?.etDate?.text = format.format(timestamp)

Solution

  • Change it to

    binding?.etDate?.setText(format.format(timestamp))