Compiler is giving me the error
Error:(97, 17) Val cannot be reassigned
but the variable is declared as var
.
Edit: You can see comments in my code. When i assign rcv = recyclerView and
chkStrictSearch = checkBox I get red underline here with above error message tooltip
Below is my code:
private var rcv: RecyclerView? = null
private var chkStrictSearch: android.widget.CheckBox? = null
private fun getMainView(): View{
return with(context){
frameLayout{
lparams(width = matchParent, height = matchParent)
//Error is below - val cannot be reassign
rcv = recyclerView{
lparams(width = matchParent, height = matchParent)
setPadding(0, resources.getDimension(R.dimen.toolbar_height).toInt(), 0, dip(48))
clipToPadding = false
}
//and here - val cannot be reassign
chkStrictSearch = checkBox{
text = "Strict Search"
}.lparams(width = wrapContent, height = wrapContent){
marginEnd = dip(24)
bottomMargin = dip(50)
gravity = Gravity.BOTTOM
}
}
}
}