Android开发中List的remove()方法

  List集合有的remove()方法有两个:                      1.remove( int location),这个方法是根据下标从集合中移除相应的对象。
	   	 2.remove(Object object),这个方法是根据对象从集合中移除第一次出现的这个对象。
  但是在Android的一次实际开发中,调用第二个方法根据一个对象一直无法删除相应的对象,所以只能使用遍历集合然后根据第一种方法去删除这个对象。
	
public void onMemberLeft(String s, IM800MultiUserChatRoomParticipant im800MultiUserChatRoomParticipant) {
    for (int i = 0; i <mIM800UserProfiles.size(); i++) {
        if (mIM800UserProfiles.get(i).getJID().equals(im800MultiUserChatRoomParticipant.getJID())){
            mIM800UserProfiles.remove(i);
        }
    }
}
  mIM800UserProfiles.remove(im800MultiUserChatRoomParticipant);这个不可行
  具体什么原因还是没有搞懂,希望大神指点
                       

更多推荐

Android开发中List的remove()方法