2011-05-02 87 views
65

我想完全隱藏自定義ExpandableListView中的groupIndicator。如何完全隱藏ExpandableListView的groupIndicator?

提供的示例here似乎沒有工作。

它暗示製備選擇器和使用expList.setGroupIndicator(選擇器),這是我複製:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/empty_icon"> 
    <item android:state_empty="true" android:drawable="@android:color/transparent"/> 
    <item android:state_expanded="true" android:drawable="@android:color/transparent" /> 
    <item android:drawable="@android:color/transparent" /> 
</selector> 

這提供了以下錯誤
ERROR/AndroidRuntime(10675): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x12/d=0x0 a=2 r=0x7f0b0013}

同樣是通過使用的類似的建議給出android:id/empty代替顏色/透明。

我該如何完全隱藏組指示符?

編輯:事實證明,該代碼工作...如果你把它放在可繪製的資源文件夾,而不是佈局。

回答

232

您是否試過改變ExpandableListView的屬性android:groupIndicator="@null"

+9

這個作品完全(@null) – eftokay83 2012-07-30 11:43:47

+0

很好的觸摸隊友!非常感謝。 – Sajmon 2013-09-05 07:48:05

+19

對於任何想以編程方式執行此操作的人,可以使用'mExpandableListView.setGroupIndicator(null)'完成此操作。 – Phil 2014-01-14 15:35:40

1

我有同樣的問題,這解決了我的問題。 在Listview的適配器中,將以下內容添加到getGroupView。

if (groupPosition == 0) { 
    convertView = layoutInflater.inflate(R.layout.blank_layout, null); 

} else { 
    convertView = layoutInflater.inflate(R.layout.group_indicator_cell,null); 
} 

這將使列表的第0組空白。

其中空白布局是佈局,其中一些視圖裏面有layout_height = 0dp。 它的工作原理!

0

你可以試試這個代碼

的ListView =(ExpandableListView)view.findViewById(R.id.listView);

listView.setGroupIndicator(null); 


listView.setChildIndicator(null);