当前位置: 代码迷 >> Android >> Android ExpandableListView 无child 时 setGroupIndicator 不需要显示的有关问题
  详细解决方案

Android ExpandableListView 无child 时 setGroupIndicator 不需要显示的有关问题

热度:382   发布时间:2016-05-01 15:46:21.0
Android ExpandableListView 无child 时 setGroupIndicator 不需要显示的问题

转自:GMAIL 邮件列表 http://comments.gmane.org/gmane.comp.handhelds.android.devel/82840

==================================================

I've been fighting with styling on ExpandableListView as well (an area
that could use some improvement in a future release).

The problem with the current implementation is in the selector element
for the group expander.? It can be found in expander_group.xml and
looks like this:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
??? <item
??????? android:state_expanded="true"
??????? android:drawable="@drawable/expander_ic_maximized" />
??? <item
??????? android:drawable="@drawable/expander_ic_minimized" />
</selector>

The problem is that it lacks a state for empty.? The code and
attributes support it (state_empty) but it isn't defined in here.
Here are the hypothetical (completely untested) steps you could use to
achieve this:

- Grab the existing expander_group.xml and put it into your drawable
directory.
- Modify it to include a section for the empty state with no image.
Something like this:
??? <item android:state_empty="true" android:drawable="@drawable/
empty"/>
- Modify your ExpandableListView element and set the group indicator
to be your private expander_group.xml

Let us know how it works out.? For myself, I need even more control so
I'm about to move to the "roll my own" stage.

?

======================分割线==================================

貌似这是个仍未修复的BUG,即便写了如下代码,问题仍然存在!

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

?

  相关解决方案