0


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

在 Windows 7 的 Eclipse 中运行 Android。

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

非常感谢。

4

2 回答 2

0

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

于 2013-08-07T22:20:16.797 回答
0

在你的 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);
于 2013-08-07T22:39:18.860 回答