当前位置: 首页 > 知识库问答 >
问题:

无法实例化以下类:Android.Support.V7.Widget.AppCompatimageView

薛坚
2023-03-14

问题:

无法实例化以下类:Android.Support.V7.Widget.AppCompatimageView

 Rendering Problems The following classes could not be instantiated:
- android.support.v7.widget.AppCompatImageView (Open Class, Show Exception, Clear Cache)

 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.  If this is an unexpected error you can also try to build the project, then manually refresh the layout.  


Tip: Try to refresh the layout.
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/main_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:weightSum="1">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginStart="10dp"
            android:layout_marginTop="18dp"
            android:text="@string/title_best_comments"
            android:textColor="@color/dark_primary"
            android:textSize="14sp" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/best_comments_rv"
            android:name="com.opera.android.news.comment.CommentFragment"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="15dp"
            app:layoutManager="LinearLayoutManager"
            tools:context="com.opera.android.news.comment.CommentFragment"
            tools:listitem="@layout/fragment_comment" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginStart="10dp"
            android:layout_marginTop="18dp"
            android:text="@string/title_latest_comments"
            android:textColor="@color/dark_primary"
            android:textSize="14sp" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/latest_comments_rv"
            android:name="com.opera.android.news.comment.CommentFragment"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            app:layoutManager="LinearLayoutManager"
            tools:context="com.opera.android.news.comment.CommentFragment"
            tools:listitem="@layout/fragment_comment" />

    </LinearLayout>
</android.support.v4.widget.NestedScrollView>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/content_rl"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/comment_large_head"
            android:layout_width="28dp"
            android:layout_height="28dp"
            app:srcCompat="@drawable/ic_comment_head_large" />

        <TextView
            android:id="@+id/name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="4dp"
            android:layout_toRightOf="@id/comment_large_head"
            android:text="Romain Beaumont" />

        <TextView
            android:id="@+id/comment_time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@id/name"
            android:layout_below="@id/name"
            android:text="7h" />

        <TextView
            android:id="@+id/content"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_alignLeft="@id/name"
            android:layout_below="@+id/comment_time"
            android:text="The previous deal was rejected by the Colombian people in a popular vote on 2 October.The previous deal was" />

        <ImageView
            android:id="@+id/comment_like_iv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            app:srcCompat="@drawable/ic_comment_unlike" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginRight="5dp"
            android:layout_toLeftOf="@id/comment_like_iv"
            android:text="32" />
    </RelativeLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/replies"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="32dp"
        android:layout_marginRight="5dp"/>
</LinearLayout>

这是跟踪堆栈。

共有1个答案

史阳晖
2023-03-14

您似乎还没有初始化ImageView。或者你能给我看看你的java代码吗?

 类似资料:
  • 我正在用AndroidLollipop(5.0)中使用的新材料设计创建一个应用程序。 我正在使用以下指南: null 创建工具栏后,收到以下错误:“以下类无法实例化:- Android.Support.v7.Widget.toolbar” 该应用程序在手机或模拟器中运行良好,但Android Studio的布局设计师不能正确显示布局。 这里有一些图像: my_awesome_toolbar.xml

  • 以下是我的构建依赖项。gradle(应用程序) 这里是build.gradle(Project)的一部分 当我访问任何文件时,它向我显示了一个错误**以下类无法实例化: 我已将Android Studio更新到最新的仍然显示错误。 我无法解决这个问题谢谢

  • 我正在尝试为我的应用程序使用。首先,我将添加到我的项目中: 然后将此代码添加到菜单中: 但是,当我启动时,我得到了以下信息: 当我按下搜索图标时,什么也没有发生:( 编辑1:

  • 发生什么事了?需要帮助~我试了很多方法,但还是解决不了 呈现问题以下类无法实例化:- Android.support.design.widget.floatingActionButton(打开类,显示异常,清除缓存)提示:在自定义视图中使用view.isineditMode()跳过代码或在IDE中显示示例数据。如果这是一个意外错误,您也可以尝试构建项目,然后手动刷新布局。 异常详细描述了java.

  • 我正在处理Android版本28,Firebase 16。 实现bottomNavView会返回以下错误: 我尝试将AppTheme样式更改为Base。主题,但不能解决它。 我的gradle应用程序: 我的风格。xml文件 我的gradle项目:

  • 问题内容: 我一直在尝试在我的应用中使用AdMob横幅广告,但始终出现错误; 无法实例化以下类:-com.google.android.gms.ads.AdView 我已经尝试过所有可以在这里和通过谷歌搜索找到的解决方案。我有; 在我的gradle中。我已经输入了这里指定的所有部分; https://developers.google.com/mobile-ads- sdk/docs/ 但是仍然没