I am new to Kotlin and android in general.
Currently making an app that is supposed to calculate a persons age in minutes, however Im getting an error saying "Unresolved reference: TextView". The thing is, as you can see, I've already imported widget.Textview.
Please help... I'm stuck on such a trivial problem. Thank you.
P.S. There have been similar questions, but the solutions either aren't applicable or have already been applied.
import android.app.DatePickerDialog
import android.content.ReceiverCallNotAllowedException
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import android.widget.Button
import android.widget.Toast
import java.util.*
class MainActivity : AppCompatActivity() {
private var tvSelectedDate : Textview? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val btndate : Button = findViewById(R.id.btndate)
tvSelectedDate = findViewById(R.id.tvSelectedDate)
btndate.setOnClickListener {
clickDatePicker()
}
}
...
CodePudding user response:
I believe this is a simple typo:
private var tvSelectedDate : Textview? = null
You have written Textview
, but should have written TextView
(with a captial "V").
CodePudding user response:
You need to specify this value in onCreate()
tvSelectedDate = findViewById(R.id.tvSelectedDate)
If this does not work, you should provide more details.
CodePudding user response:
Simply using databinding to get view id and handle alot of issues