我需要创建一个顶部有标题栏的布局和一个包含n个部分的列表视图。这个
每个部分的列表头都有两个不同的按钮,它们必须是可点击的,并且可以相互独立地聚焦。这是布局的代码:
<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/