1
我有一个处理recyclerview的问题,当我打开另一个活动后返回活动时,它会复制我显示的所有项目。有没有什么办法解决这一问题?RecyclerView重复每个项目
和列表视图一样,它只是自动清除列表,然后再次显示。你能告诉我怎么样?感谢
的OnCreate
int x = 0;
for(String Name : property_name){
JSONObject jsonObject = arrayResponse.getJSONObject(x);
property_id[x] = jsonObject.getString("property_id");
property_name[x] = jsonObject.getString("property_name");
type[x] = jsonObject.getString("property_type");
price[x] = jsonObject.getString("price");
address[x] = jsonObject.getString("address");
ListingNearby listingNearby = new ListingNearby(property_id[x], property_name[x], type[x], price[x], Math.round(distance[x]));
x++;
list.add(listingNearby);
}
recyclerView = (RecyclerView) findViewById(R.id.ln_recycler_view);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
adapter = new ListingNearbyAdapter(list);
recyclerView.setAdapter(adapter);
我不知道要放什么的onResume使列表视图清除列表,然后再次显示它。
看起来你已经搞乱了你的'onResume' ... –
我应该把什么放在onResume? –
当我不知道你的代码是什么样的时候,我可以怎样帮助你? –