无法在Android应用程序中正确查看列表视图中的列表视图

问题描述:

我想在我的android应用程序中显示来自非常通用的JSON字符串的数据。一个视图/屏幕应显示任意数量的“细节”,其中每个细节具有任意数量的“值”。我试图在一个ListView中使用一个ListView,并且所有的数据很好地放入每个列表中,但列表不会完全显示(见下图)。无法在Android应用程序中正确查看列表视图中的列表视图

在屏幕的下半部分是第一个ListView。它包含许多TextView标签(例如Usage and Info),它们又有许多值(单位,sw版本等)。这些值放在显示TextView的新列表中。

顶部也是一个ListView,但显示正常。

看起来像这样:

第一部分,与所述两个列表,第一个(细)和第二(问题)状态选项卡:

<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/tabStatus"> 

     <ListView android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1" android:id="@+id/listThingStatus"/> 

     <ListView android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1" android:id="@+id/listThingDetails"/> 

    </LinearLayout> 

与标签和第二ListView的下部的ListView:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
      android:layout_width="fill_parent" android:layout_height="70px">  
       <LinearLayout android:orientation="vertical" android:layout_width="0dip" android:layout_weight="1" android:layout_height="wrap_content">  
        <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="30px" android:id="@+id/textDetails" /> 
        <ListView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/listThingValues"/>             
       </LinearLayout> 
    </LinearLayout> 

最后第二的ListView内TextViews:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
      android:layout_width="fill_parent" android:layout_height="70px">  
       <LinearLayout android:orientation="horizontal" android:layout_width="0dip" android:layout_weight="1" android:layout_height="wrap_content" android:gravity="center_vertical"> 
        <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="30px" android:id="@+id/textValuesLabel" />   
        <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="30px" android:gravity="right|center" android:id="@+id/textValuesUnits" />  
       </LinearLayout> 
    </LinearLayout> 

结果是这样的(见图片),其中内部列表中的内容大部分是“隐藏”的(SW版本和下面的文本等)。我几乎在任何地方都使用“wrap_content”,但内容太包裹在这里:(。我如何以及在何处格式化我的XML以使内部列表中的内容正确显示?

图像(来自仿真器,但手机上的结果相同): http://i.imgur.com/8mcDq.png

+0

你有没有考虑使用ExpandableListview代替嵌套的列表视图,你做的方式。 ? – Marmoy

+0

Android应用程序应具有与等效的iPhone应用程序相同的外观,以便列表类型目前不是选项。将建议这一点,但。谢谢! – Christoffer

+0

您可以自定义可扩展列表的外观,但是您想介绍一下它在这种情况下不适用的方式吗? – Marmoy

放置一个ListView一个ListView内只会给你带来麻烦

尝试使用ExpandableListView代替

+0

呵呵。正如我上面所说,现在不是一个选项。将继续尝试并使当前列表正常工作,直到允许我使用另一个外观布局。谢谢! – Christoffer

+0

@Christoffer:如果第二个列表具有*有限的*数量的行,则使用“LinearLayout”并动态添加行。如果你需要放置两个'ListView',你将需要自己处理触摸。相信我,那只会带来痛苦和痛苦:) – Macarse

+0

好吧,尝试将行添加到LinearLayout而不是第二个列表中,并且它效果更好。谢谢! – Christoffer