GridView.LayoutParams doesn't exist in Kotlin?

Amiraslan :

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:

enter image description here

It works in Java, but not in Kotlin.

So, why is that? And how can I use GridView.LayoutParams in Kotlin?

dipdipdip :

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.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=466575&siteId=1