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