【问题标题】:Hide exapandable list view icon with zero child size具有零子大小的隐藏可扩展列表视图图标
【发布时间】:2014-03-22 13:28:23
【问题描述】:

我正在开发一个使用自定义可扩展列表视图的应用程序。当我单击列表视图时,我的图标会发生变化。当子大小为零时,我不想添加组指示器图标。请帮忙

提前致谢

【问题讨论】:

    标签: android expandablelistview


    【解决方案1】:

    This 有很大帮助。

    代码片段:

    对于 state_empty,您可以设置一个不同的图像,它不是 令人困惑,或者,只是使用透明颜色来显示任何内容......

    将此项目与其他项目一起添加到您的有状态绘图中......

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

    所以,你的指标可以是这样的:

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_empty="true" android:drawable="@android:color/transparent"/>
        <item android:state_expanded="true" android:drawable="@drawable/my_icon_max" />
        <item android:drawable="@drawable/my_icon_min" />
    </selector>
    

    解释:

    android:state_empty: - the element does not have any child
    android:state_expanded: - state when it is expanded
    android:drawable: - normal state, that is the cell has children but its not expanded
    

    这样设置指标:

    getExpandableListView().setGroupIndicator(getResources().getDrawable(R.drawable.indicator));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多