gpt4 book ai didi

Android Jetpack Compose AdapterList 崩溃

转载 作者:行者123 更新时间:2023-12-03 23:47:45 26 4
gpt4 key购买 nike

我在 Android Jetpack Compose 中使用 AdapterList。在列表中我有可点击的组件。
当我开始滚动而不触摸并退出该适配器列表时,它崩溃了。可能是图书馆问题。

提前致谢。

我在用...

 //Jetpack Component

implementation 'androidx.ui:ui-framework:0.1.0-dev09'
implementation 'androidx.ui:ui-layout:0.1.0-dev09'
implementation 'androidx.ui:ui-material:0.1.0-dev09'
implementation 'androidx.ui:ui-foundation:0.1.0-dev09'
implementation 'androidx.ui:ui-tooling:0.1.0-dev09'

适配器列表
AdapterList(data = model.seats, modifier = Modifier.weight(1f).fillMaxSize()) { seat ->
ItemSeat(seat)}

项目 list
@Composable
fun ItemSeat(seat: Seat) {
Clickable(onClick = {},
modifier = Modifier.drawBackground(color = colorResource(id = R.color.color_cd3f34))
.fillMaxWidth()) {
Text(text = "Seat ${seat.no}")
}
}

崩溃日志
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.nextorder.pos, PID: 4821
java.lang.IllegalStateException: LayoutCoordinate operations are only valid when isAttached is true
at androidx.ui.core.LayoutNodeWrapper.localToRoot(LayoutNodeWrapper.kt:169)
at androidx.ui.core.LayoutNodeWrapper.localToGlobal(LayoutNodeWrapper.kt:165)
at androidx.ui.core.pointerinput.PointerInputFilter.getPosition$ui_platform_release(PointerInput.kt:100)
at androidx.ui.core.pointerinput.Node.dispatchChanges(HitPathTracker.kt:326)
at androidx.ui.core.pointerinput.Node.dispatchChanges(HitPathTracker.kt:332)
at androidx.ui.core.pointerinput.Node.dispatchChanges(HitPathTracker.kt:332)
at androidx.ui.core.pointerinput.Node.dispatchChanges(HitPathTracker.kt:332)
at androidx.ui.core.pointerinput.Node.dispatchChanges(HitPathTracker.kt:332)
at androidx.ui.core.pointerinput.Node.dispatchChanges(HitPathTracker.kt:332)
at androidx.ui.core.pointerinput.Node.dispatchChanges(HitPathTracker.kt:332)
at androidx.ui.core.pointerinput.Node.dispatchChanges(HitPathTracker.kt:332)
at androidx.ui.core.pointerinput.NodeParent.dispatchChanges(HitPathTracker.kt:194)
at androidx.ui.core.pointerinput.HitPathTracker.dispatchChanges(HitPathTracker.kt:100)
at androidx.ui.core.pointerinput.HitPathTracker.dispatchChanges$default(HitPathTracker.kt:91)
at androidx.ui.core.pointerinput.PointerInputEventProcessor.process(PointerInputEventProcessor.kt:67)
at androidx.ui.core.AndroidComposeView.onTouchEvent(AndroidOwner.kt:648)
at android.view.View.dispatchTouchEvent(View.java:13471)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3216)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2888)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3222)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2904)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:754)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1879)
at android.app.Activity.dispatchTouchEvent(Activity.java:3494)
at androidx.appcompat.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:712)
at android.view.View.dispatchPointerEvent(View.java:13719)

最佳答案

从 dev15 版本开始,AdapterList已弃用,取而代之的是 LazyColumnFor .如果您使用 LazyColumnFor,您指出的问题应该得到解决。

关于Android Jetpack Compose AdapterList 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61501587/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com