0

コンパイラは私にエラーを与えています

エラー:(97, 17) Val を再割り当てできません

しかし、変数は として宣言されていvarます。

編集:私のコードでコメントを見ることができます。rcv = recyclerView
chkStrictSearch = checkBoxを割り当てると、上記のエラー メッセージのツールチップと共に赤い下線が表示されます

以下は私のコードです:

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
            }
        }
    }
}  
4

1 に答える 1