2012-08-29 9 views
5

संभव डुप्लिकेट नहीं बच्चों के साथ समूहों के लिए ExpandableListView सूचक को छिपाने के लिए: कोई बच्चों के साथ समूहों के लिए
ExpandableListView - hide indicator for groups with no childrenकैसे

छिपाने सूचक

main.xml

<ExpandableListView 
android:id="@+id/elv" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:groupIndicator="@drawable/selector"> 
</ExpandableListView> 

selector.xml

<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/expanded" /> 
    <item android:drawable="@drawable/collapse" /> 
</selector> 

यह मेरी आईसीएस के लिए काम नहीं करता है, ऐसा लगता है सभी की स्थिति ध्वस्त हो गई है कि समूहों खाली

+0

ऐसा लगता है कि यह एक बग है, क्योंकि एडाप्टर के getChildrenCount (int groupPosition) को ध्वस्त समूहों के लिए कभी भी नहीं कहा जाता है। इसलिए उन्हें खाली माना जाता है। –

उत्तर

11

इस पर एक कोशिश है कर रहे हैं:

getExpandableListView().setGroupIndicator(null); 

वरना,

if (getChildrenCount(groupPosition) == 0) { 
     indicator.setVisibility(View.INVISIBLE); 
    } 
else { 
     indicator.setVisibility(View.VISIBLE); 
     indicator.setImageResource(isExpanded ? R.drawable.group_expanded : R.drawable.group_closed); 
    } 
+0

इस समारोह को कहां रखा जाए? – Mahesh

+0

'GetGroupView' – Swayam

+9

में GetGroupView में सूचक कैसे प्राप्त करें? – corban