2013-01-31 68 views
5

我有一個expandableList使用兩個遊標:1組爲組,另一組爲與組相關的子組。 用戶可以在此可擴展列表上使用過濾器(alphaindexer)。 我想在沒有孩子的時候完全刪除組視圖(不僅是圖標:))。這就像我刪除空組的行。在ExpandableList中隱藏組視圖

我嘗試在bindgroupview方法中設置可見性。我嘗試設置組視圖的佈局高度....結果是一樣的,空間仍然保留並顯示。

這是可能的嗎?我該怎麼做這個功能?

一些下面的代碼:

// mMapSeqArticle is TreeMap<Object, ArrayList<Object>) 
mSequenceAdapter = new SequenceCommandeAdapter(getActivity(), mMapSeqArticle); 

public class SequenceCommandeAdapter extends BaseExpandableListAdapter { 
     Object[] mGroupSeq = null; 
     Map<Sequence, ArrayList<TicketArticle>> mContent; 

     public SequenceCommandeAdapter(Context c, 
       Map<Sequence, ArrayList<TicketArticle>> map) { 
      mContent = map; 
      mGroupSeq = mContent.keySet().toArray(); 
     } 

     @Override 
     public Object getChild(int groupPosition, int childPosition) { 
      Sequence s = (Sequence) mGroupSeq[groupPosition]; 
      return ((ArrayList<TicketArticle>) (mContent.get(s))) 
        .get(childPosition); 
     } 

     @Override 
     public long getChildId(int groupPosition, int childPosition) { 
      Sequence s = (Sequence) mGroupSeq[groupPosition]; 
      return ((ArrayList<TicketArticle>) (mContent.get(s))) 
        .get(childPosition).mId; 
     } 

     @Override 
     public View getChildView(int groupPosition, int childPosition, 
       boolean isLastChild, View convertView, ViewGroup parent) { 
      // retrouve la valeur de la sequence 
      TicketArticle ta = (TicketArticle) getChild(groupPosition, 
        childPosition); 
      if (convertView == null) { 
       convertView = LayoutInflater.from(getActivity()).inflate(
         R.layout.adapter_row_article_details_table, null); 
      } 



      convertView.setTag(groupPosition + ":" + childPosition); 
      return convertView; 
     } 

     @Override 
     public int getChildrenCount(int groupPosition) { 
      Sequence s = (Sequence) mGroupSeq[groupPosition]; 
      return ((ArrayList<TicketArticle>) (mContent.get(s))).size(); 
     } 

     @Override 
     public Object getGroup(int groupPosition) { 
      return (Sequence) mGroupSeq[groupPosition];// mContent.get(groupPosition); 
     } 

     @Override 
     public int getGroupCount() { 
      return mContent.size(); 
     } 

     @Override 
     public long getGroupId(int groupPosition) { 
      return ((Sequence) mGroupSeq[groupPosition]).key; 
     } 

     @Override 
     public View getGroupView(int groupPosition, boolean isExpanded, 
       View convertView, ViewGroup parent) { 
      if (convertView == null) { 
       convertView = LayoutInflater.from(getActivity()).inflate(
         R.layout.adapter_header_sequence_details_table, null); 
      } 


      convertView.setTag(null); 
      return convertView; 
     } 

     @Override 
     public boolean hasStableIds() { 
      // TODO Auto-generated method stub 
      return false; 
     } 

     @Override 
     public boolean isChildSelectable(int groupPosition, int childPosition) { 
      // TODO Auto-generated method stub 
      return true; 
     } 
    } 

回答

0

我沒有看到bindGroupView方法在你的代碼,但是從你所描述的東西,它聽起來就像你在正確的軌道上。爲了使組行完全從可展開列表視圖中消失,我必須設置GONE的所有子視圖(包括佈局)的可見性。否則,空行仍然存在。

如果您發佈R.layout.adapter_header_sequence_details_table的內容,我會更好地瞭解您需要做的其他事情。