ListView inside ListView items




我有一个ListView,它保存了每个项目中的许多数据视图。(每个项目包含不同的数据)
该ListView的一个视图是另一个ListView(换句话说,ListView中的ListView)
运行代码时,我的主列表显示了包括ListView在内的所有视图(包括其内容适配器数据;至少您可以在不接触的情况下看到,因为内部ListView中有很多数据)。问题是,你可以看到内部ListView的内容,但它的内容比XML中显示的内容更白,就好像它没有聚焦一样,而且内部ListView是不可滚动的,比如当我试图滚动时,它会滚动主ListView。我一直在寻找关于我的问题的线索,但我找不到任何相关的线索:"不建议在ListView中使用ListView"而没有解释,或者"使用ExpandableList",但ExpandableList无法满足我的需求或满足我的设计。恐怕我必须有ListView,而不是列表对话框。

在Windows 7的Eclipse中运行Android。

如何根据XML
使内部ListView数据保持原样->以及如何使内部ListView可滚动?

非常感谢。

如果您正在寻找与iOS的TableLayout类似的东西(可滚动项中的可滚动项),则ExpandableListView不适合您。然后,您需要创建自己的ViewGroup类来执行此操作。

在xml文件中使用类似的内容

     <ScrollView
         android:id="@+id/scrollView1"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentBottom="false"
         android:layout_alignParentLeft="true"
         android:layout_alignParentRight="true"
         android:fadingEdge="none"
         android:overScrollMode="never" >
         <TableLayout
             android:id="@+id/tableLayout1"
             android:layout_width="match_parent"
             android:layout_height="2dp" >
         </TableLayout>
     </ScrollView>

您可以通过编程将添加到表格布局中

TableLayout TL = (TableLayout)findViewById(R.id.tableLayout1);
TableRow tableRow = new TableRow(getApplicationContext());

只需将视图添加到您创建的每一行(例如图像视图)

LinearLayout rowLayout = new LinearLayout(getApplicationContext());
rowLayout.setOrientation(LinearLayout.HORIZONTAL);
rowLayout.add(ImageView1);

最新更新