【问题标题】:Sectioned ListView and ExpandableListView分段 ListView 和 ExpandableListView
【发布时间】:2010-08-20 14:37:17
【问题描述】:

我需要创建一个顶部带有标题栏的布局和带有 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 中心按钮,两个按钮都会被单击。我没有找到解决这个问题的方法。

有人可以帮忙吗?

非常感谢!

【问题讨论】:

  • "每个部分的列表标题都有两个不同的按钮,它们必须可以相互独立地单击和聚焦。" ——为什么?
  • 这是我正在开发的应用程序所需的功能。单击第一个按钮启动一个活动,单击第二个按钮启动另一个。无论如何,使用您的实现最乏味的问题是当您添加除 ListView 之外的另一个布局时的焦点。

标签: android listview expandablelistview


【解决方案1】:

试试 Merge adapter https://github.com/commonsguy/cwac-merge 怎么样?它允许你添加多个列表和按钮!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-30
    • 1970-01-01
    相关资源
    最近更新 更多