0

電話でアプリを実行するとエラーが発生しますが、エミュレーターを介して起動すると正常に動作します。エミュレーターは私の電話と同じ 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);
4

1 に答える 1

0

解決しました!!!!

私はさまざまなことを試していましたが、最終的には、私のイメージ bg_seznam に問題があったことが問題でした。正確な理由はわかりませんが、どういうわけか小さすぎました。xhdpiフォルダに入れました。私がしたのは、通常の2倍にサイズを変更することだけでしたが、今では魅力的に機能します.

CFlex の助けを借りて Tenx さん、logcat についてのあなたの考えがなければ、私は成功しません!

于 2012-08-09T14:18:05.333 に答える