2011-01-21 65 views
1

我實現了我的SimpleExpandableListAdapter,我試圖自定義章節標題。要做到這一點,我傳遞給constructor定製TextView的ID爲groupTo參數:SimpleExpandableListAdapter章節標題

setListAdapter(new SimpleExpandableListAdapter(this, 
                groupsData, 
                android.R.layout.simple_expandable_list_item_1, 
                new String[]{SECTION}, 
                new int[]{R.id.list_group_title}, 
                innerData, 
                0, 
                null, 
                new int[]{}){ /*my code here*/ }); 

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/list_group_title" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textSize="20dip" /> 

的問題是,什麼都不顯示出來!整個事情都是空白的,好像這個視圖不存在。 任何想法,爲什麼,或者我可以讀懂解決這個問題的任何鏈接?謝謝!

回答

0
MyAdapter ma = new MyAdapter(this,groupsData,android.R.layout.simple_expandable_list_item_1,new String[]{SECTION}, new int[]{R.layout.list_group_title},innerData,0,null,new int[]{}); 
    setListAdapter(ma); 


    private static class MyAdapter extends SimpleExpandableListAdapter 
    { 
      LayoutInflater layoutInflater; 
      int title; 

      public MyAdapter(Context context,List<? extends Map<String, ?>> groupData,int groupLayout,String[ ] groupFrom,int[ ] groupTo,List<? extends List<? extends Map<String, ?>>> childData,int childLayout,String[ ] childFrom, int[ ] childTo) 
      {   
       super(context,groupData,groupLayout,groupFrom,groupTo,childData,childLayout,childFrom,childTo); 
       title = groupTo[0]; 
       layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      } 
      @Override 
      public View getGroupView(int groupPosition,boolean isExpanded,View convertView,ViewGroup parent) 
      { 
       return (TextView)layoutInflater.inflate(title,null); 
      } 
    } 

將它膨脹在getGroupView訣竅。不過,我不明白爲什麼它不會自動傳遞給構造函數super