ListView并发症

时间:2015-02-06 11:42:06

标签: android listview scrollview

因为根据屏幕尺寸可能无法显示每个标签中的信息,所以我添加了一个滚动视图。列表视图显示数据库中的信息,但它不会在屏幕上传播。它只占屏幕的一小部分,我只能滚动一小部分。如果我有两组信息,我希望看到两行,但我只看到一行,我可以在其中滚动查看第二组信息。但是当我删除滚动视图时,我的列表视图显示它应该是,但然后其他选项卡受到影响因为我无法滚动查看其他字段。 以下是我的主要活动:

<TabHost
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/tabHost">


    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="match_parent"></TabWidget>

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/scrollView"
            android:fillViewport="true">

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

            <!--Overview Tab Starts-->


            <LinearLayout
                android:id="@+id/overviewTab"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical">

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

            </LinearLayout>


            <!--Overview Tab ends-->

            <!--Base Data Tab starts-->

                    <LinearLayout
                        android:id="@+id/baseDataTab"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:orientation="vertical"
                        android:padding="15dp">

                        //the needed views go here//

                    </LinearLayout>

            <!--Base Data Tab ends-->

            <!--Task Tab starts-->

                <LinearLayout
                    android:id="@+id/taskTab"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:orientation="vertical"
                    android:padding="15dp">

                    //the needed views go here//

                </LinearLayout>

            <!--Task Tab ends-->

            <!--Survey Tab starts-->

                <LinearLayout
                    android:id="@+id/surveyTab"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:orientation="vertical"
                    android:padding="15dp">

                    //the needed views go here//

                </LinearLayout>


            <!--Survey Tab ends-->

        </FrameLayout>

        </ScrollView>
    </LinearLayout>
</TabHost>

1 个答案:

答案 0 :(得分:0)

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabHost"
android:layout_width="match_parent"
android:layout_height="fill_parent" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </TabWidget>

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true" >

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <!-- Overview Tab Starts -->

            <LinearLayout
                android:id="@+id/overviewTab"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical" >

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

            <!-- Overview Tab ends -->


            <!-- Base Data Tab starts -->

            <LinearLayout
                android:id="@+id/baseDataTab"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical"
                android:padding="15dp" >
            </LinearLayout>

            <!-- Base Data Tab ends -->


            <!-- Task Tab starts -->

            <LinearLayout
                android:id="@+id/taskTab"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical"
                android:padding="15dp" >
            </LinearLayout>

            <!-- Task Tab ends -->


            <!-- Survey Tab starts -->

            <LinearLayout
                android:id="@+id/surveyTab"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical"
                android:padding="15dp" >
            </LinearLayout>

            <!-- Survey Tab ends -->

        </FrameLayout>
    </ScrollView>
</LinearLayout>

您的layout_height和width属性存在一些问题。我改变了一些,这应该工作;-)