android-jetpack-compose

What is the Jetpack Compose equivalent of RecyclerView or ListView?

巧了我就是萌 提交于 2020-07-09 14:34:05
问题 In Jetpack Compose, how can I display a large list of data while laying out only the visible items, instead of composing and laying out every item on the initial layout pass? This would be similar to RecyclerView and ListView in the View toolkit. One could use a for loop to place all of the components inside of a Column in a VerticalScroller , but this would result in dropped frames and poor performance on larger numbers of items. Note: this is intended as a canonical self-answered question

What is the Jetpack Compose equivalent of RecyclerView or ListView?

微笑、不失礼 提交于 2020-07-09 14:33:09
问题 In Jetpack Compose, how can I display a large list of data while laying out only the visible items, instead of composing and laying out every item on the initial layout pass? This would be similar to RecyclerView and ListView in the View toolkit. One could use a for loop to place all of the components inside of a Column in a VerticalScroller , but this would result in dropped frames and poor performance on larger numbers of items. Note: this is intended as a canonical self-answered question

How to get Current state or context in Jetpack Compose

拈花ヽ惹草 提交于 2020-03-20 05:48:51
问题 fun createListItem(itemIndex: Int) { Padding(left = 8.dp, right = 8.dp, top = 8.dp, bottom = 8.dp) { FlexRow(crossAxisAlignment = CrossAxisAlignment.Center) { expanded(1.0f) { Text("Item $itemIndex") } inflexible { Button( "Button $itemIndex", style = ContainedButtonStyle(), onClick = { Toast.makeText( this@MainActivity, "Item name $itemIndex", Toast.LENGTH_SHORT ).show() }) } } } } I try to make Toast in a normal way. but I got the error I tried a lot of multiples source but failed. 回答1: You

How to get Current state or context in Jetpack Compose

吃可爱长大的小学妹 提交于 2020-03-20 05:46:20
问题 fun createListItem(itemIndex: Int) { Padding(left = 8.dp, right = 8.dp, top = 8.dp, bottom = 8.dp) { FlexRow(crossAxisAlignment = CrossAxisAlignment.Center) { expanded(1.0f) { Text("Item $itemIndex") } inflexible { Button( "Button $itemIndex", style = ContainedButtonStyle(), onClick = { Toast.makeText( this@MainActivity, "Item name $itemIndex", Toast.LENGTH_SHORT ).show() }) } } } } I try to make Toast in a normal way. but I got the error I tried a lot of multiples source but failed. 回答1: You

Unresolved reference: DrawImage

筅森魡賤 提交于 2020-03-12 05:34:28
问题 I'm trying call DrawImage() on my code, I'm following this tutorial Jetpack Tutorial, But I'm getting this error.: Unresolved reference: DrawImage I tried implement on build.gradle, this lib.: implementation 'androidx.ui:ui-foundation:0.1.0-dev04' But I getting this error.: Executing tasks: [clean, :app:assembleDebug] in project C:\Users\samue\Desktop\Projetos Kotlin\first-jetpack Task :clean Task :app:clean Task :app:preBuild UP-TO-DATE Task :app:preDebugBuild UP-TO-DATE Task :app