2012-06-01 51 views
0

正如標題所說,我的listview不會被填充。 我知道適配器正在充滿3個項目,我通過它進行調試。但我的XML沒有顯示任何東西:android listview沒有得到更新

適配器是一個全局變量,如果它應該做任何事情。 代碼:

private void listChange(CustomCursor c){ 

    List<SimpleListItem> itemsList = new ArrayList<SimpleListItem>(); 

    while (c.moveToNext()) { 
     String picture = c.getString("picture"); 
     String text = c.getString("name"); 
     itemsList.add(new SimpleListItem(text, picture)); 

    } 
    productListAdapter = new ProductAdapter(getBaseContext(),R.layout.product_item, itemsList); 
    setListAdapter(productListAdapter); 
    productListAdapter.notifyDataSetChanged(); 


} 

活動的XML:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" > 

    <dk.foo.views.PageHeaderView 
     android:id="@+id/header" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 
    </dk.foo.views.PageHeaderView> 

    <ListView 
     android:id="@+id/android:list" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

    </ListView> 

</LinearLayout> 
+0

添加聲明ListView的完整佈局文件。 – Luksprog

+0

抱歉,stackoverflow代碼插入錯誤;) –

+0

包括完整的源代碼。這將有助於 –

回答

2

修改您LinearLayoutorientationvertical如果你想看到的ListView

現在用你的父母LinearLayout設置爲horizontalorientation和自定義視圖的widthPageHeaderView設置爲FILL_PARENT,你ListView被推出屏幕。

+0

杜,非常感謝! –