0

正如标题所说,我的列表视图不会被填满。我知道适配器装满了 3 个项目,并通过它进行了调试。但我的 xml 根本没有显示任何内容:

如果应该做任何事情,适配器是一个全局变量。代码:

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>
4

1 回答 1

2

如果您想查看 ,请修改您orientation的。LinearLayoutverticalListView

现在orientation,您的父级LinearLayout设置为horizontalwidth您的自定义视图PageHeaderView设置为FILL_PARENT,您将ListView被推出屏幕。

于 2012-06-01T13:44:46.773 回答