【问题标题】:Expandable List Indicator可扩展列表指示器
【发布时间】:2012-08-28 21:16:05
【问题描述】:

我有一个可展开的列表

两个问题

  1. (我见过一些类似的问题 但从未找到答案)我该怎么做 隐藏箭头(组指示器) 没有孩子的时候

    我尝试在适配器中这样做

    public View getGroupView(int groupPosition, boolean isExpanded, View convertView,ViewGroup parent) {
    if(getChildrenCount(groupPosition)==0) {
          // how do i hide the group indicator ?
    }
    

    但是我卡住了那么,如何修改 空组的组指示器?

  2. 如何有不同的行为 您单击箭头(展开 group) vs 你点击标题 小组(参加活动)

【问题讨论】:

  • 你有没有弄清楚你的答案,尤其是问题 2?thx

标签: android


【解决方案1】:
  1. 您必须设置具有不同状态的GroupIndicator 可绘制对象。查看StateListDrawable,也许为“state_empty”指定一个空drawable。

【讨论】:

  • 我用了这个 schemas.android.com/apk/res/android"> ..但是一切都变得透明了——这个人也有孩子
【解决方案2】:

只需在drawable文件夹中创建一个group_indicator.xml文件,使用代码指定父状态,

<item android:state_empty="true" android:drawable="@android:color/transparent"></item>
<item android:state_expanded="true" android:drawable="@drawable/arrowdown"></item>
<item android:drawable="@drawable/arrowright"></item>

然后使用代码在 Expandable 列表视图中指定这个样式,

<ExpandableListView
        android:id="@+id/android:list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:groupIndicator="@drawable/group_indicator"
        android:layout_weight="1" >
    </ExpandableListView>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-09
    • 2013-04-17
    • 1970-01-01
    • 2017-05-06
    • 2013-03-08
    • 1970-01-01
    • 2011-09-25
    相关资源
    最近更新 更多