I want to use GridView
and according to the documentation, in adapter I can use this line in adapter:
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
Well, converting it to Kotlin, it says:
It works in Java, but not in Kotlin.
So, why is that? And how can I use GridView.LayoutParams
in Kotlin?
Try one of the following:
imageView.setLayoutParams(AbsListView.LayoutParams(85, 85))
imageView.setLayoutParams([email protected](85, 85))
Since GridView doesn't have it's own implementation of LayoutParams you have to choose an implementation of its superclass AbsListView
. You can decide if you want to add the GridView@
prefix.
GridView
doesnt have inner class LayoutParams
, it uses AbsListView.LayoutParams
so just change code to
imageView.layoutParams = AbsListView.LayoutParams(85,85)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With