I'm trying to change height and width of ListView item programmatically, but I'm getting an "val cannot be reassigned error", can you please tell me witch exact val can't be reassigned here and how can I finally set height and width for List is my custom adapter?
class Game6Adapter(
private val mContext: Context,
private val resourceLayout: Int,
private val items: ArrayList<Drawable>
) : ArrayAdapter<Drawable>(mContext, resourceLayout, items) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
var v: View? = convertView
var vi: LayoutInflater = LayoutInflater.from(mContext)
v = vi.inflate(resourceLayout, null)
val p = getItem(position)
var imageView = v!!.findViewById(R.id.game_6_item_image) as ImageView
imageView.setImageDrawable(items[position])
var layoutParams = parent.layoutParams
imageView.height = (parent.height * 0.1).toInt() // val cannot be reassigned
imageView.width = (parent.height * 0.1).toInt() val cannot be reassigned
imageView.requestLayout()
return v!!
}
}