2012-11-19 1 views
1

확장 가능한 목록을 하나 사용하고 있으며 사용자가있을 때마다 변경이있을 때마다 (런타임에) 채팅중인 사용자의 존재를 보여줍니다. 어댑터를 새로 고치지 만 전혀 새로 고침하지 않습니다.Expandable List Adapter가 전혀 새로 고침되지 않음

는 여기에 내가 sendbroadcast 방법을 사용하여 서비스에서이 수신 전화 어댑터

/** Set Adapter here */ 
     adapter = new UserMenuAdapter(this, groupNames, childs); 
     setListAdapter(adapter); 
     object = this; 

을 설정하는 코드

이고, 나는 이미 onReceive 것을 확인했지만 목록이 상쾌하지 않다.

BroadcastReceiver UpdateList = new BroadcastReceiver() { 
     @Override 
     public void onReceive(Context context, Intent intent) { 

      groupChileItem(); 
      adapter.notifyDataSetChanged(); 

     } 
    }; 

// groupChileitem (방법)

private void groupChileItem(){ 
     /***###############GROUP ARRAY ############################*/ 
     final ArrayList<String> groupNames = new ArrayList<String>(); 

     if(XMPPConn.mfriendRequestList.size() > 0){ 
      groupNames.add("Request ("+XMPPConn.mfriendRequestList.size()+")"); 
     }else{ 
      groupNames.add("Request (0)"); 
     } 
     chatUser = dbHelper.getChatUser(); 
     groupNames.add("Chats ("+chatUser.size()+")"); 
     groupNames.add("Contacts (" + XMPPConn.mfriendList.size() + ")"); 
     groupNames.add("CGM Groups (" + XMPPConn.mGroupList.size() + ")"); 
     if(XMPPConn.mfriendPendingList.size() > 0){ 
      groupNames.add("Pending ("+XMPPConn.mfriendPendingList.size()+")"); 
     }else{ 
      groupNames.add("Pending (0)"); 
     } 

     mXMPPConn.getGroup(); 
     categoryList = dbHelper.getAllCategory(); 
     /**Group From Sever*/ 
     if (XMPPConn.mGroupList.size() > 0) { 
      for (int g = 0; g < XMPPConn.mGroupList.size(); g++) { 
       mXMPPConn.getGroupContact(XMPPConn.mGroupList.get(g).groupName); 
       groupNames.add(XMPPConn.mGroupList.get(g).groupName + "(" 
         + XMPPConn.mGroupContactList.size()+ ")"); 
      } 
     } 
     this.groupNames = groupNames; 

     /*** ###########CHILD ARRAY * #################*/ 
     ArrayList<ArrayList<ChildItems>> childs = new ArrayList<ArrayList<ChildItems>>(); 
     ArrayList<ChildItems> child = new ArrayList<ChildItems>(); 
     /**child for request frieds*/ 
     if(XMPPConn.mfriendRequestList.size() > 0){ 
      for(int i = 0; i < XMPPConn.mfriendRequestList.size(); i++){ 
       child.add(new ChildItems(XMPPConn.mfriendRequestList.get(i).friendNickName, 
         "Waiting for Authorization",0,null)); 
      } 
     }else{ 
      child.add(new ChildItems("No Request list","",0,null)); 
     } 
     childs.add(child); 
     /**Child for chat */ 
     child = new ArrayList<ChildItems>(); 
     if(chatUser.size() > 0){ 
      for(int i = 0; i < chatUser.size(); i++){ 
       child.add(new ChildItems(userName(chatUser.get(i)), "",0,null)); 
      } 
     }else{ 
      child.add(new ChildItems("--No History--", "",0,null)); 
     }  
     childs.add(child); 
     /**Child for contact list*/ 
     child = new ArrayList<ChildItems>(); 
     child.add(new ChildItems("", "",0,null)); 
     if (XMPPConn.mfriendList.size() > 0) { 
      for (int n = 0; n < XMPPConn.mfriendList.size(); n++) { 
       child.add(new ChildItems(XMPPConn.mfriendList.get(n).friendNickName, 
         XMPPConn.mfriendList.get(n).friendStatus, 
         XMPPConn.mfriendList.get(n).friendState, 
         XMPPConn.mfriendList.get(n).friendPic)); 
      } 
     } 
     childs.add(child); 
     /************** CGM Group Child here *********************/ 
     child = new ArrayList<ChildItems>(); 
     child.add(new ChildItems("", "",0,null)); 

     if (XMPPConn.mGroupList.size() > 0) { 
      for (int grop = 0; grop < XMPPConn.mGroupList.size(); grop++) { 
       child.add(new ChildItems(
         XMPPConn.mGroupList.get(grop).groupName + " (" 
         + XMPPConn.mGroupList.get(grop).groupUserCount 
         + ")", "",0,null)); 
      } 
     } 
     childs.add(child); 

     /**Pending friend*/ 
     child = new ArrayList<ChildItems>(); 
     if(XMPPConn.mfriendPendingList.size()> 0){ 
      for(int i = 0; i < XMPPConn.mfriendPendingList.size(); i++){ 
       child.add(new ChildItems(XMPPConn.mfriendPendingList.get(i).friendNickName, 
         "Waiting for Authorization",0,null)); 
      } 
     }else{ 
      child.add(new ChildItems("No Pending list","",0,null)); 
     } 
     childs.add(child); 
     /************************ Group Contact List *************************/ 
     if (XMPPConn.mGroupList.size() > 0) { 
      for (int g = 0; g < XMPPConn.mGroupList.size(); g++) { 
       /** Contact List */ 
       mXMPPConn.getGroupContact(XMPPConn.mGroupList.get(g).groupName); 
       child = new ArrayList<ChildItems>(); 
       for (int con = 0; con < XMPPConn.mGroupContactList.size(); con++) { 
        child.add(new ChildItems(
          XMPPConn.mGroupContactList.get(con).friendNickName, 
          XMPPConn.mGroupContactList.get(con).friendStatus,0,null)); 
       } 
       childs.add(child); 
      } 
     } 
     this.childs = childs; 

    } 

누구나 내가 뭘 잘못 말해주십시오?

답변

3

내가 다시 어댑터를 설정하는 대신 그래서 당신은 사용해 볼 수 있습니다 notifyDataSetChanged()

를 사용하여 시도를 주장하는 것, 사용

setListAdapter(adapter); 

intead,

adapter.notifyDataSetChanged();