2012-08-07 88 views
1

嗨,我有我的Android應用程序的問題。問題是當我嘗試設置新的視圖。未知的充氣錯誤與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(); 
      } 
     } 

in line 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> 

所以任何想法?

回答

1

嘗試通過這樣一來替換這行代碼

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

的:

v = vi.inflate(R.layout.list, parent, false); 
+0

總共有同樣的結果:S – gabrjan 2012-08-07 13:58:40

+0

'bg_seznam'如何繪製?它是一個圖像或XML可繪製? – StenaviN 2012-08-07 14:07:22

+0

這是一個.png圖像 – gabrjan 2012-08-07 14:11:15

1

我想你的代碼,並能正常工作在我的身邊。
也許做一個乾淨的將有助於:項目 - >清潔 - >選擇您的項目 - >確定。

+0

Tryied and it's steal not working:S – gabrjan 2012-08-07 14:05:35