java.util.ConcurrentModificationException 组合喷气背包

时间:2021-01-07 00:55:28

标签: android-jetpack-compose

我想对表面应用动态渐变。当显示新图像时,基于该图像的颜色渐变会发生变化。就像在谷歌示例中一样,

@Composable
fun DatingHomeScreen() {

var imageId = remember { mutableStateOf(R.drawable.camelia) }
val defaultBitmap = imageResource(id = imageId.value).asAndroidBitmap()
var currentBitmap = mutableStateOf(defaultBitmap)
val swatch = generateDominantColorState(currentBitmap.value)
val dominantColors = listOf(Color(swatch.rgb), Color.Black)

 Box(
        modifier = boxModifier.verticalGradientBackground(
            dominantColors
        )
    ){
    IconButton(
       onClick = {
           imageId.value = getRandomImageId()
             }
          )
   }

}

但在第三个图像应用程序崩溃后:

   java.util.concurrentmodificationexception

0 个答案:

没有答案