sgdvas
April 1, 2018, 5:14am
1
Greetings!
I am getting an error while trying to assing a textview to another textview variable
I have the import for the textview resource at the top
import com.company.app.R.id.TextViewToAssign
…
lateinit var textViewToChange:TextView
…
textViewToChange = TextViewToAssign
It says:
“Type mismatch required TextView Found Int”
I am using
ext.kotlin_version = ‘1.2.31’
Am I using the correct syntax?
md
April 1, 2018, 10:32am
2
You are importing the id, not the view
Try this link:
https://kotlinlang.org/docs/tutorials/android-plugin.html
Or you can use findViewById(ID)
sgdvas
April 2, 2018, 1:04am
3
Today, I tried again with:
import kotlinx.android.synthetic.main.layout.*
And it worked, however, and as strange it may sounds, it works randomly: for yesterday textviews, it pointed to a nullpointer, and today is poitning as nullpointer for the textviews created from today.