/** 刷新当前的列表 */
 public void refreshList() {
   friends = FriendsManager.getContacterList();
   ContacterExpandAdapter tempViewAdapter =
       new ContacterExpandAdapter(SingleChatListActivity.this, friends);
   contacterList.setAdapter(tempViewAdapter);
   // expandAdapter.notifyDataSetChanged();
 }
  private void init() {
    // 获取好友情况
    contacterList = (ListView) findViewById(R.id.main_expand_list);
    expandAdapter = new ContacterExpandAdapter(this);
    contacterList.setAdapter(expandAdapter);

    // 获取要添加好友的邀请人
    //		inviteList = (ListView) findViewById(R.id.main_invite_list);
    //		inviteAdapter = new InviteAdapter();
    //		inviteList.setAdapter(inviteAdapter);
    //		// 为添加好友的邀请人设置监听器
    //		inviteList.setOnItemClickListener(inviteListClick);
    // 添加好友按钮
    addFriendbtn = (ImageButton) findViewById(R.id.addFriend_btn);
    addFriendbtn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            addSubscriber();
          }
        });
    searchEt = (EditText) findViewById(R.id.searchEditText);
    searchEt.addTextChangedListener(
        new TextWatcher() {
          // 当输入框的文字改变时,执行以下方法。
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            List<User> tempList = new ArrayList<User>(); // 好友链表
            tempList = friends;
            for (int i = 0; i < tempList.size(); i++) {
              User hr = tempList.get(i);
              if ((hr.getName()).indexOf(s.toString()) == -1) {
                tempList.remove(i);
              }
            }
            ContacterExpandAdapter tempViewAdapter =
                new ContacterExpandAdapter(SingleChatListActivity.this, tempList);
            contacterList.setAdapter(tempViewAdapter);
            if ((s.toString().trim()).equals("")) {
              refreshList();
            }
          }

          @Override
          public void afterTextChanged(Editable arg0) {}

          @Override
          public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {}
        });

    // 获取当前登录用户的所有好友
    friends = FriendsManager.getContacterList();
    // 设置好友列表子项点击监听器
    contacterList.setOnItemClickListener(
        new OnItemClickListener() {
          // 列表选项被点击
          public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
            // 获取点击的好友
            User friend = friends.get(position);
            createChat(friend);
          }
        });
    // 设置好友列表长按事件
    contacterList.setOnItemLongClickListener(friendListOnItemLongClickListener);
  }