1

こんにちは、Android アプリに問題があります。問題は、新しいビューを設定しようとしたときです。

    public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
        if (v == null) {
            try{
            LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.list, null);
            }
            catch(Exception e){
                String a=e.toString();
            }
        } 

行 v = vi.inflate(R.layout.list, null); 私はこのエラーが発生します:

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

これも私のlist.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>
    </TableLayout>

アイデアはありますか?

4

2 に答える 2

1

コードのこの行を置き換えてみてください

v = vi.inflate(R.layout.list, null);

これによって:

v = vi.inflate(R.layout.list, parent, false);
于 2012-08-07T13:53:56.937 に答える
1

あなたのコードを試してみましたが、私の側では問題なく動作します。
プロジェクト -> クリーン -> プロジェクトを選択 -> OK.

于 2012-08-07T13:57:39.443 に答える