2010-07-06 39 views
6

我有一個擴展列表擴展列表指示燈

於是兩個問題

  1. (我見過索姆類似的問題 但從來沒有找到答案)我怎麼 隱藏箭頭(組指標) 時,有沒有孩子

    我試圖做到這一點在適配器

    public View getGroupView(int groupPosition, boolean isExpanded, View convertView,ViewGroup parent) { 
    if(getChildrenCount(groupPosition)==0) { 
         // how do i hide the group indicator ? 
    } 
    

    但我卡住所以,如何修改 組指標爲空組?

  2. 如何有不同的行爲時 你點擊箭頭(擴展 組)與您單擊的 組標題(去一個活動)

+1

你有沒有想出你的答案,尤其是問題2?thx – Snake 2013-01-19 16:30:15

回答

4
  1. 你有設置一個GroupIndicator可繪製的不同狀態。檢查出StateListDrawable,也許爲「state_empty」指定一個null drawable。
+2

我使用了這個 ..但everthing變得透明---也有chlid也 – Rockin 2011-08-10 12:27:59

2

剛創建的文件夾繪製一個group_indicator.xml文件中使用代碼指定父狀態,

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

然後在擴展列表視圖指定這個風格使用代碼,

<ExpandableListView 
     android:id="@+id/android:list" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:groupIndicator="@drawable/group_indicator" 
     android:layout_weight="1" > 
    </ExpandableListView>