gpt4 book ai didi

android - 分节式 ListView 和 ExpandableListView

转载 作者:太空狗 更新时间:2023-10-29 15:24:16 24 4
gpt4 key购买 nike

我需要创建一个顶部有标题栏和包含 n 个部分的 ListView 的布局。这每个部分的列表标题都有两个不同的按钮,它们必须彼此独立地可单击和可聚焦。这是布局的代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical">

<include layout="@layout/title_bar" />

<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1.0"
/>
</LinearLayout>

我尝试了这两种解决方案,但我发现了我无法在这两种解决方案中解决的问题:

1) 使用分段适配器(可以找到源代码 here )。没有标题栏它工作正常但有标题栏默认的焦点算法不再工作。
2) 使用 ExpandableListAdapter(在这种情况下,显然布局中的 ListView 变成了 ExpandableListView)。它工作正常,但如果我在组布局上按下 dpad 中心按钮,则会单击两个按钮。我没有找到解决这个问题的方法。

有人可以帮忙吗?

非常感谢!

最佳答案

尝试合并适配器如何 https://github.com/commonsguy/cwac-merge它允许您添加多个列表和按钮!!

关于android - 分节式 ListView 和 ExpandableListView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3531885/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com