简体   繁体   中英

Can we initialize a list from a specific index in lazy column?

I want to initialize a list from a specific index in lazy column.

For example: I have a list of 10 items. I want the list to load from 5. index when first loaded.

The method I'm using now is to scroll to the 5th index after loading the list. But instead I want to initialize the list directly from an index I want. Is it possible?

you can use itemsIndexed() extension and filter the list

LazyColumn() {
    itemsIndexed(viewModel.list) { index, item ->
        if(index >5){
           // your composable here
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM