使用hashSet去重

private void showData(String json) {
    Gson gson = new Gson();
    Data data = gson.fromJson(json, Data.class);
    if(page == 5010){
        list.clear();
    }
    list.addAll(data.getData());
    //使用HashSet去除重复
    HashSet hashSet = new HashSet(list);
    list.clear();
    list.addAll(hashSet);
    adapter.notifyDataSetChanged();
    list_view.postDelayed(new Runnable() {
        @Override
        public void run() {
            list_view.onRefreshComplete();
        }
    },1000);
}

猜你喜欢

转载自blog.csdn.net/weixin_42470335/article/details/81269849
今日推荐