ExpandableListView - 隐藏的指标为无子女群体 [英] ExpandableListView - hide indicator for groups with no children

查看:307
本文介绍了ExpandableListView - 隐藏的指标为无子女群体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ExpandableListView ,是有办法隐藏组指示灯组,没有孩子?

解决方案

安卓groupIndicator 属性采用启用状态绘制。也就是说,你可以设置不同的图像不同的状态。

在该集团一直没有孩子,对应的状态为state_empty

请参阅以下参考链接:

<一个href="http://developer.android.com/reference/android/widget/ExpandableListView.html#attr_android:groupIndicator">this和

有关 state_empty ,你可以设置不同的图像而不是混乱,或者干脆用透明色来显示什么...

添加此项目中有状态绘制与人相处......

 &LT;项目安卓state_empty =真正的机器人:可绘制=@机器人:彩色/透明/&GT;
 

所以,你statelist可以是这样的:

 &LT;选择的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android&GT;
    &LT;项目安卓state_empty =真正的机器人:可绘制=@机器人:彩色/透明/&GT;
    &LT;项目安卓state_expanded =真正的机器人:可绘制=@可绘制/ my_icon_max/&GT;
    &LT;项目机器人:可绘制=@可绘制/ my_icon_min/&GT;
&LT; /选择器&GT;
 

如果你使用的是ExpandableListActivity,您可以设置的onCreate的groupindicator如下:

<$p$p><$c$c>getExpandableListView().setGroupIndicator(getResources().getDrawable(R.drawable.my_group_statelist));

我已经测试了这是工作。

In an ExpandableListView, is there a way to hide the group indicator for groups with no children?

解决方案

The android:groupIndicator property takes a state enabled drawable. That is, you can set different image for different states.

When the group has no children, the corresponding state is 'state_empty'

See these reference links:

this and this

For state_empty, you can set a different image which is not confusing, or, simply use transparent color to display nothing...

Add this item in your stateful drawable along with others....

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

So, your statelist can be like this:

<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>

In case you are using an ExpandableListActivity, you can set the groupindicator in onCreate as follows:

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

I have tested this to be working.

这篇关于ExpandableListView - 隐藏的指标为无子女群体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆