问题描述
在 ExpandableListView
,是有办法隐藏组指示灯组,没有孩子?
在安卓groupIndicator
属性采用启用状态绘制。也就是说,你可以设置不同的图像不同的状态。
在该集团一直没有孩子,对应的状态为state_empty
请参阅以下参考链接:
this和这
有关 state_empty
,你可以设置不同的图像而不是混乱,或者干脆用透明色来显示什么...
添加此项目中有状态绘制与人相处......
<项目安卓state_empty =真正的机器人:可绘制=@机器人:彩色/透明/>
所以,你statelist可以是这样的:
<选择的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目安卓state_empty =真正的机器人:可绘制=@机器人:彩色/透明/>
<项目安卓state_expanded =真正的机器人:可绘制=@可绘制/ my_icon_max/>
<项目机器人:可绘制=@可绘制/ my_icon_min/>
< /选择器>
如果你使用的是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:
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 - 隐藏的指标为无子女群体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!