https://kotlinlang.org logo
#compose
Title
# compose
s

Santhosh Kumar

06/18/2020, 11:32 AM
How can we create a grid list recyclerview adapter? I couldn't find any properties on top of modifiers. As of now AdapterList supports a linear vertical scrolling.
a

allan.conda

06/18/2020, 12:07 PM
Don’t think it’s supported yet. Right now I create an AdapterList of Rows
v

Vinay Gaba

06/18/2020, 4:37 PM
There used to be a
Table
api but it was deprecated. An alternative version should be available soon!
👍 1
t

Timo Drick

06/24/2020, 10:24 AM
maybe this small wrapper is helpfull:
Copy code
@Composable
fun <T>ViewTableList(columns: Int = 2, item: List<T>, itemCallback: @Composable() (T) -> Unit) {
    key(item, columns) {
        AdapterList(data = item.chunked(columns)) { rowList ->
            Row {
                rowList.forEach {
                    itemCallback(it)
                }
                val emptyRows = (columns - rowList.size)
                repeat(emptyRows) {
                    Spacer(modifier = Modifier.weight(1f))
                }
            }
        }
    }
}