How to update the text of Textview in kotlin. Set Text on-create function works but when I tried outside main fun it says unresolved ref.
How can I declare widget for reuse TextView for update the Text Value? I don't have exp with kotlin. Can somebody help me?
class MediaPickedActivity : AppCompatActivity() {
val fullName = "Test User"
var score = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_media_picked)
val Tv_test = findViewById(R.id.tv_text) as TextView
Tv_test.setText("$fullName :: $score ")
if (score in 0..300) {
score = 5
setText()
}
}
private fun setText() {
// Error is here. I can't set text.
Tv_test.setText("$fullName :: $score ")
}
}