首页 > 代码库 > Androidの疑难杂症之加载布局报Error inflating class <unknown>

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

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