ListView项目中的ListView

时间:2013-08-07 22:07:28

标签: android android-listview


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

在Windows 7中的Eclipse中运行Android。

如何制作内部ListView数据 - >根据XML
以及如何使内部ListView可滚动?

非常感谢。

2 个答案:

答案 0 :(得分:0)

如果你正在寻找类似于iOS的TableLayout(可滚动项目内的可滚动项目)和ExpandableListView的东西,那么你找不到解决方案。然后,您需要创建自己的ViewGroup类来执行该操作。

答案 1 :(得分: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());

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

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