Androidの疑难杂症之加载布局报Error inflating class <unknown>

android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>

出现这种错误有可能是,你的布局当中某个wedget的属性出错,比如引用了?attr/xxxx,但是你的主题里面却没有给这个attr赋值。

复制代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/llPlaceHolderLoading"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:background="?attr/primary_page_background"
    android:gravity="center"
    android:orientation="vertical"
    android:visibility="visible" >

    <ProgressBar
        style="@style/AppTheme.Widget.Progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp" />

    <TextView
        android:id="@+id/tvLoadTip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="16dp"
        android:text="?attr/loading_tip"
        android:textColor="@color/progress_tips_text_color"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</LinearLayout>
复制代码

像这样的在style里面没有把attr赋值,这个界面是加载不错来,并且报错

02-03 17:24:50.746: E/AndroidRuntime(10702): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.realtor.app.extranet.cmls/net.realtor.app.extranet.cmls.ui.activity.TestActivity}: android.view.InflateException: Binary XML file line #12: Error inflating class android.widget.ProgressBar

posted @   bvin  阅读(6661)  评论(0编辑  收藏  举报
编辑推荐:
· Brainfly: 用 C# 类型系统构建 Brainfuck 编译器
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
阅读排行:
· DeepSeek 全面指南,95% 的人都不知道的9个技巧(建议收藏)
· 对比使用DeepSeek与文新一言,了解DeepSeek的关键技术论文
· Brainfly: 用 C# 类型系统构建 Brainfuck 编译器
· DeepSeekV3+Roo Code,智能编码好助手
· AI编程:如何编写提示词
点击右上角即可分享
微信分享提示