Estoy haciendo un proyecto en kotlin. Me lanzó un error de null pointer exception en los findViewbyId.
private fun setSizeBoard(){
var iv: ImageView
val display = windowManager.defaultDisplay
val size = Point()
display.getSize(size)
val width = size.x
var width_dp = (width / getResources().getDisplayMetrics().density)
var lateralMarginsDP = 0
val width_cell = (width_dp - lateralMarginsDP ) / 8
val heigth_cell = width_cell
for (i in 0..7){
for(j in 0..7){
//Error aquí
iv = findViewById(resources.getIdentifier("c$i$j","id",packageName))
var height = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,heigth_cell,getResources().getDisplayMetrics()).toInt()
var width = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,width_cell,getResources().getDisplayMetrics()).toInt()
iv.setLayoutParams(TableRow.LayoutParams(width,height))
}
}
}