我是新的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
然后你应该有一个适配器,每个父项只有一个子项,你可以通过以下方式处理这些项: - 显示第一个父项的两个视图,第二个视图显示一个视图,第三个视图显示所有视图。
添加一些代码,以便我可以向您展示案例的解决方案。