从数组列表中删除一个元素后,U​​I不会更新

时间:2014-02-18 11:13:38

标签: android xmpp asmack

我正在写一个聊天应用程序。点击一个按钮我试图从列表中删除选定的朋友并且它正常工作但是在移除朋友时UI没有得到更新

  private void removeFriend(String remfri) {
       removefri = remfri;

            {
                try {
                    Constants.connection.getRoster().setSubscriptionMode(Roster.SubscriptionMode.accept_all);
                    Constants.connection.getRoster().createEntry(removefri, removefri, null);

                    Collection<RosterEntry> entries = Constants.connection.getRoster().getEntries();
                    for (RosterEntry entry : entries) 
                    {
                        System.out.println("name..."+entry.getUser()+"...type.."+entry.getType());
                        if(entry.getType()==ItemType.none)
                        {
                            Presence unsubscribe = new Presence(Presence.Type.unsubscribe);
                            unsubscribe.setTo(removefri);
                            Constants.connection.sendPacket(unsubscribe);

                           // usersList.clear();
                            usersList.remove(removefri);
                            Log.d("removed"," the best friend " + removefri);

粘贴参考代码:http://pastie.org/8744959

1 个答案:

答案 0 :(得分:1)

删除后使用adapter.notifyDataSetChanged();