gpt4 book ai didi

android - ConstraintSet.createHorizo​​ntalChain 非法参数异常 : must have 2 or more widgets in a chain

转载 作者:行者123 更新时间:2023-11-29 23:13:54 27 4
gpt4 key购买 nike

我在使用 ConstraintLayout 设置水平链约束时遇到错误:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: me.optimize.debug, PID: 18532
java.lang.RuntimeException: Unable to start activity ComponentInfo{me.optimize.debug/me.optimize.post.PostActivity}: java.lang.IllegalArgumentException: must have 2 or more widgets in a chain
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.IllegalArgumentException: must have 2 or more widgets in a chain
at android.support.constraint.ConstraintSet.createHorizontalChain(ConstraintSet.java:1032)
at android.support.constraint.ConstraintSet.createHorizontalChain(ConstraintSet.java:1005)

我基本上是在添加约束,例如:

set.createHorizontalChain(buttonA.id, ConstraintSet.LEFT, buttonC.id, ConstraintSet.RIGHT, arrayOf(buttonA.id, buttonB.id, buttonC.id).toIntArray(), arrayOf(0f, 0f).toFloatArray(), 0)

我有超过 2 个小部件,因为我正在传递 buttonAbuttonBbuttonC

最佳答案

好吧,在写我的问题时,我决定查看我在 GitHub 上找到的 android.support.constraint.ConstraintSet.createHorizo​​ntalChain 代码并猜猜是什么:

createHorizontalChain

chainIds 数组和weights 数组必须相同!

关于android - ConstraintSet.createHorizo​​ntalChain 非法参数异常 : must have 2 or more widgets in a chain,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55630480/

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