是否可以在可扩展ListView的水平显示子视图? [英] Is possible displays child views in horizontally of expandable ListView?

查看:68
本文介绍了是否可以在可扩展ListView的水平显示子视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的Android开发人员. 通常,可展开的ListView组和子视图垂直显示. 但是我希望组视图垂直显示,而子视图水平显示. 子视图可能是3个项目.有可能吗?

解决方案

我认为您可以通过创建一个水平滚动视图作为子项来解决此问题,然后在该视图中添加所需的任何子项.

<HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/child1"
            android:textSize="15sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/child2"
            android:textSize="12sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/child3"
            android:textSize="10sp"/>
    </HorizontalScrollView>

假设您最多拥有三个子项,并且具有以下架构的列表

Parent
   child1 child2
Parent
   child1
Parent 
   child1 child2 child3

然后,您应该有一个适配器,每个父对象只有一个子项,并且您可以通过以下方式处理这些项 -为第一个父级显示两个视图,为第二个父级显示一个视图,为第三个父级显示所有视图.

添加一些代码,以便我向您展示解决方案.

I am new Android developer. Generally Expandable ListView Group and Child View shows vertically. But I want Group View show vertically but Child Views shows horizontally. Child view may be 3 items. Is it possible?

解决方案

I think that you can handle this by creating a horizontal scrollview to be your child item, and then in this view you can add whatever children you want.

<HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/child1"
            android:textSize="15sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/child2"
            android:textSize="12sp"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/child3"
            android:textSize="10sp"/>
    </HorizontalScrollView>

Let's say that you are having maximum three child items and you are having a list with the following architecture

Parent
   child1 child2
Parent
   child1
Parent 
   child1 child2 child3

Then you should have an adapter that have only one child item for each parent and you handle these items by - show two views for the first parent, one view for the second and all views for the third.

Add some of your code so that i can show you the solution on your case.

这篇关于是否可以在可扩展ListView的水平显示子视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆