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に何を置くべきですか? –
コードがどのように見えるかわからないときは、どうすればお手伝いできますか? –