gpt4 book ai didi

安卓工作室 : Can't add Views on GridLayout. android/view/View$OnUnhandledKeyEventListener

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

我已经为此苦苦挣扎了好几个小时。为什么会这样?我正在学习网站上的类(class)(不确定我是否可以提及),一切都应该完美无缺,但它不适合我。本质上,我想做的是做一个“四连胜”游戏,我想使用 GridLayout 并在其中添加 ImageViews。当我尝试将 ImageView 添加到 gridLayout 时,它们没有显示。它们“存在”,但并没有真正显示出来。到目前为止我尝试了什么:

  • 改变布局的高度和宽度
  • 玩转背景,可见度
  • 用谷歌搜索解决这个问题。
  • 为网格布局添加垂直方向
  • 再次从头开始创造一切
  • “使缓存无效/重新启动...”

    Stack Trace

    java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener
    at org.jetbrains.android.uipreview.ModuleClassLoader.load(ModuleClassLoader.java:180)
    at com.android.tools.idea.rendering.RenderClassLoader.findClass(RenderClassLoader.java:61)
    at org.jetbrains.android.uipreview.ModuleClassLoader.findClass(ModuleClassLoader.java:118)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.jetbrains.android.uipreview.ModuleClassLoader.loadClass(ModuleClassLoader.java:213)
    at android.support.v7.widget.GridLayout.isLayoutRtlCompat(GridLayout.java:679)
    at android.support.v7.widget.GridLayout.onLayout_Original(GridLayout.java:1082)
    at android.support.v7.widget.GridLayout.onLayout(GridLayout.java)
    at android.view.View.layout_Original(View.java:19659)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:19645)
    at android.view.ViewGroup.layout(ViewGroup.java:6075)
    at android.support.constraint.ConstraintLayout.onLayout_Original(ConstraintLayout.java:1858)
    at android.support.constraint.ConstraintLayout.onLayout(ConstraintLayout.java)
    at android.view.View.layout_Original(View.java:19659)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:19645)
    at android.view.ViewGroup.layout(ViewGroup.java:6075)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout_Original(View.java:19659)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:19645)
    at android.view.ViewGroup.layout(ViewGroup.java:6075)
    at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
    at android.view.View.layout_Original(View.java:19659)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:19645)
    at android.view.ViewGroup.layout(ViewGroup.java:6075)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:346)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:384)
    at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:544)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:678)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

    activity_main.xml

    <?xml version="1.0" encoding="utf-8"?>

    <android.support.v7.widget.GridLayout
    android:layout_width="368dp"
    android:layout_height="359dp"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/board2"
    android:visibility="visible"
    app:columnCount="3"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.6"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="1.0"
    app:rowCount="3">

    <ImageView
    android:id="@+id/imageView"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:background="@drawable/red"
    android:visibility="visible"
    app:srcCompat="@drawable/red" />
    </android.support.v7.widget.GridLayout>

最佳答案

我是 Android 的新手,我也遇到同样的错误,但我发现网格布局的一种简单方法是尝试使用基本 <GridLayout>标记而不是 <android.support.v7.widget.GridLayout>便宜的方式...

关于安卓工作室 : Can't add Views on GridLayout. android/view/View$OnUnhandledKeyEventListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51379900/

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