Edit textview from different class


I am working on a bluetooth android application that will need to display some data to the screen… I have a layot kotlin file and I have a seperate BluetoothService.kt file for bluetooth connection. I have established the connection now i have problems displaying data to the layout.

How do I access the TextView from the bluetooth class? I have tried creating a function test that would change the textview, but I cannot access it from bluetooth class.

class data_display_tab : AppCompatActivity(){

override fun onCreate(savedInstanceState: Bundle?) {


    toHeight.setOnClickListener {
        startActivity(Intent(this, lift_tab::class.java))


fun test()
    weight_frontleft.text = "Hello"

If you’re not using DataBinding or ViewBinding, I think you need to do this:

lateinit var view: TextView
// (Replace textview_id with the actual attribute name
// that's in the data_display XML layout file.)
view = findViewById(R.id.textview_id)
view.weight_frontleft.text = "Hello"