FATAL EXCEPTION: main KotlinNullPointerException

后端 未结 4 464
悲哀的现实
悲哀的现实 2021-01-20 10:46

This is my first time building an android application. However when i run the app on my Virtual Device, it stopped working and keeps crashing. The error says something about

4条回答
  •  情歌与酒
    2021-01-20 11:19

    Because your date EditText is null.Before use editText initialise editText like this

    var date = findViewById(R.id.date) as? EditText
    

    then set the value of date

    date?.setText("15-11-2017")
    date?.isEnabled = false
    

提交回复
热议问题