2013-01-31 40 views
5

Tôi có một danh sách mở rộng bằng cách sử dụng hai con trỏ: 1 cho nhóm, một con khác cho trẻ em có liên quan đến nhóm. Người dùng có thể sử dụng bộ lọc (alphaindexer) trên danh sách có thể mở rộng này. Tôi muốn xóa hoàn toàn chế độ xem nhóm khi không có trẻ em (không chỉ biểu tượng :)). Nó giống như tôi xóa dòng cho nhóm trống.Ẩn chế độ xem Nhóm trong Danh sách mở rộng

Tôi cố gắng đặt chế độ hiển thị đi theo phương pháp bindgroupview. Tôi cố gắng đặt chiều cao bố cục cho chế độ xem nhóm .... Kết quả giống nhau, không gian vẫn được giữ và hiển thị.

Có thể và làm cách nào để tôi có thể thực hiện tính năng này?

Một số mã dưới đây:

// 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; 
     } 
    } 

Trả lời

0

Tôi không thấy phương pháp bindGroupView trong mã của bạn, nhưng từ những gì bạn đã mô tả, có vẻ như bạn đang đi đúng hướng. Tôi phải đặt chế độ hiển thị của tất cả các chế độ xem phụ (bao gồm bố cục) của GONE để hàng nhóm biến mất hoàn toàn khỏi chế độ xem danh sách có thể mở rộng. Nếu không, hàng trống vẫn còn.

Nếu bạn đăng nội dung của R.layout.adapter_header_sequence_details_table, tôi sẽ có ý tưởng tốt hơn về những thứ khác bạn cần thực hiện GONE.

Các vấn đề liên quan