1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| @Composable fun ListScreen( modifier: Modifier = Modifier ) { val lazyColumnState = rememberLazyListState() val lazyRowState = rememberLazyListState()
val list = listOf(1,2,3,4,5,6,7,8,9,10) LazyColumn( state = lazyColumnState, content = { item { LazyRow( modifier = modifier.height(250.dp), state = lazyRowState, content = { itemsIndexed( items = list, key = {index: Int, item: Int -> index }, ){index,item -> Text( text = "Row $item", modifier = modifier .padding(16.dp) .background(Color.Yellow) .width(100.dp) .fillMaxHeight(), textAlign = TextAlign.Center ) } } ) }
itemsIndexed( items = list, key = { index: Int, item: Int -> index} ){index: Int, item: Int -> Text( text = "Column itemsIndexed:index = $index,item = $item", modifier = modifier .padding(16.dp) .background(Color.Cyan) .fillMaxWidth() ) } item { Divider( modifier = modifier.fillMaxWidth()) }
items( items = list, key = null ){item: Int -> Text( text = "Column items:item = $item", modifier = modifier .padding(16.dp) .background(Color.Green) .fillMaxWidth() ) } } ) }
|