0

In my activity_main.xml I have a TextView:

    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello World!"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            android:id="@+id/str" />

In my MainActivity.kt I have declared:

str.setText("Changed")

IntelliJ says that it cannot find declaration to go to. How can I fix this? I have looked to other answers and they do not work.

w1cked
  • 35
  • 8

1 Answers1

0

How silly of me... All I had to do was to add this line of code:

val str = findViewById<TextView>(R.id.str)
w1cked
  • 35
  • 8