高度为wrap_content时,Android列表视图不显示数据

时间:2014-05-15 12:14:33

标签: android listview

我对显示的列表视图项有疑问。

<?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="vertical" >

<include
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    layout="@layout/view_top_tab_bar" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:cacheColorHint="#00000000"
    android:orientation="vertical" >

    <TextView
        style="@style/black_bold_20"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="6dip"
        android:layout_marginRight="6dip"
        android:background="@drawable/shape_bg_common"
        android:gravity="center"
        android:paddingBottom="10dip"
        android:paddingTop="10dip"
        android:text="@string/news_and_offers" />

    <com.handmark.pulltorefresh.library.PullToRefreshListView
        xmlns:ptr="http://schemas.android.com/apk/res-auto"
        android:id="@+id/News_sv_PullToRefresh"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center_vertical"
        android:paddingLeft="3dip"
        android:paddingRight="3dip"
        ptr:ptrAnimationStyle="flip"
        ptr:ptrMode="pullFromStart" >
    </com.handmark.pulltorefresh.library.PullToRefreshListView>
</LinearLayout>

</LinearLayout>

如果我将height的{​​{1}}设置为ListView,则列表不会显示单行。

我已在warp_content文件中将所有元素height设置为wrap_content

请建议任何解决方案。

1 个答案:

答案 0 :(得分:0)

// Try this way,hope this will help you to solve your problem...

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <include
        layout="@layout/view_top_tab_bar" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:cacheColorHint="#00000000"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="#FFFFFF">
        <TextView
            style="@style/black_bold_20"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="6dip"
            android:layout_marginRight="6dip"
            android:background="@drawable/shape_bg_common"
            android:gravity="center"
            android:paddingBottom="10dip"
            android:paddingTop="10dip"
            android:text="@string/news_and_offers" />

        <com.handmark.pulltorefresh.library.PullToRefreshListView
            xmlns:ptr="http://schemas.android.com/apk/res-auto"
            android:id="@+id/News_sv_PullToRefresh"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center_vertical"
            android:paddingLeft="3dip"
            android:paddingRight="3dip"
            ptr:ptrAnimationStyle="flip"
            ptr:ptrMode="pullFromStart" >
        </com.handmark.pulltorefresh.library.PullToRefreshListView>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>
相关问题