1. 程式人生 > >使用hashSet去重

使用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);
}