【问题标题】:I get error on phone but on emulator it works fine我在手机上收到错误,但在模拟器上它工作正常
【发布时间】:2012-08-08 08:08:54
【问题描述】:

当我在手机上运行应用程序时出现错误,但是当我通过模拟器启动它时它运行正常。模拟器与我的手机在相同的 2.1 froyo 上运行。

我得到的错误是

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

问题发生在这段代码中:

    LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    v = vi.inflate(R.layout.list, null);

当我试图夸大这个视图时。顺便说一句,在我的 xml 代码中一切正常,否则它也无法在模拟器上运行。

但如果你认为这是我的帮助,那就是:

    <?xml version="1.0" encoding="utf-8"?>
    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="15dp"
        android:background="@drawable/bg_seznam" >
        <TextView
            android:id="@+id/item_title"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="17dp"
            android:textColor="#ffffff"
            android:textSize="20dp"
            android:textStyle="bold"
            android:typeface="serif" >
        </TextView>         
    </TableRow>
    <TableRow
        android:layout_width="fill_parent"
        android:paddingBottom="5dp"
        android:paddingTop="5dp" >
        <TextView
            android:id="@+id/item_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.6"
            android:ellipsize="end"
            android:maxLines="1"
            android:paddingLeft="17dp"
            android:scrollHorizontally="true"
            android:singleLine="false"
            android:textSize="18dp"
            android:textStyle="bold"
            android:typeface="serif" >

        </TextView>            

        <TextView
            android:id="@+id/item_distance"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.3"
            android:ellipsize="end"
            android:maxLines="1"
            android:scrollHorizontally="true"
            android:singleLine="false"
            android:textColor="#3b5688"
            android:textSize="18dp"
            android:textStyle="bold"
            android:typeface="serif" >

        </TextView>            



        <ImageView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.1"
            android:contentDescription="@string/hello_world"
            android:src="@drawable/naprej" />


    </TableRow>


    </TableLayout>

编辑:顺便说一句,如果我使用它也是一样的:

   LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   v = vi.inflate(R.layout.list, null);

【问题讨论】:

  • 请发布整个堆栈跟踪
  • 对不起,我不完全了解这是如何完成的:S
  • 你只放Error inflating class &lt;unknown&gt;,请把logcat的其他行贴出来。
  • 我从 error.tostring() 复制了这一行,在我的 logcat 中有很多行,所以我不知道哪些行有帮助...
  • 我知道问题出在 logcat 的这几行中,它们经常重复 08-08 10:23:46.999: E/libgps(173): onUnsol: cmd 0x04 plen 57 08-08 10 :23:46.999:E/libgps(173):oem_unsol_gps_measurement:num_sv 0 08-08 10:23:46.999:E/libgps(173):oem_unsol_gps_measurement:used_in_fix_mask 0000014E

标签: android android-emulator


【解决方案1】:

解决了!!!!

我一直在尝试不同的事情,但结果却是,整个问题是我的图像 bg_seznam 有问题。我不知道究竟是为什么,但不知何故它太小了。我在 xhdpi 文件夹中有它。我所做的只是将其大小调整为正常的两倍,现在它就像一个魅力。

Tenx 求助 CFlex,如果没有你对 logcat 的想法,我不会成功!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-23
    • 2012-10-25
    • 1970-01-01
    • 2014-12-16
    相关资源
    最近更新 更多