我们可以在滚动视图中拥有列表视图吗?



我已经将滚动视图应用于整个布局,并且该布局有一个列表视图。 在模拟器中运行应用程序时,两个滚动视图都为整个布局工作一个滚动视图,为列表视图工作另一个滚动视图(两者都工作正常(。 但是当我在手机中安装我的应用程序时,只有外部滚动视图正常工作 列表视图的滚动视图不起作用。任何人都可以告诉我我问题的原因和解决方案。

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg4"
android:orientation="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true" >
 <ListView
        android:id="@+id/listViewTickets"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10dp" >
    </ListView>
<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:layout_marginBottom="70dp"
    android:orientation="horizontal"
    >
    <Button
        android:id="@+id/btnNew"
        android:layout_width="80dp"
        android:layout_height="30dp"
        android:background="@drawable/btnnew" />
    <Button
        android:id="@+id/btnUpdate"
        android:layout_width="80dp"
        android:layout_height="30dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:background="@drawable/edit" />
</LinearLayout>

列表视图的内容是动态显示的。

我发现YouTube视频Google I/O 2010 - ListView的世界是必不可少的手表。其中提到永远不要使用多个滚动小部件,除非它们在不同的轴上滚动。

列表视图已可滚动,因此无法将其添加到滚动视图中。这是一个类似的问题和负责ListView的Google工程师的答案:如何将列表视图放入滚动视图而不折叠?

最新更新