I need to get a Note()
object from my room database from a background thread and set the title of the note as my activity title, but title = note.title
doesn't work and I see my application name in the toolbar. I have also tried supportActionBar?.title
and toolbar.title
but none of them solved the issue. I'm sure that the database is giving me the right data and I don't know where is the problem. Any help is appreciated.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_show_note)
setSupportActionBar(toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
override fun onResume() {
super.onResume()
intent.extras?.also {
val id = it.getInt(ID_EXTRA)
Thread(Runnable {
note = db.noteDao().getNote(id)
runOnUiThread {
title = note.title
tvShowNote.text = note.note
tvShowTime.text = note.time.format()
}
}).start()
}
}