2016-05-29 84 views

risposta

0

RecyclerView ricicla la vista. Quando si eliminano i dati, chiamare il metodo notifyItemChanged(pos) o notifyDataSetChanged().

+0

Sepasgozaram, (Grazie, ha lavorato per me) – RayaCoder

0

È il tuo notifyDataSetChanged() che è il problema.

Verificare di averlo usato correttamente.

Cioè:

private void parseJsonFeed(JSONArray response) { 

for (int i = 0; i < response.length(); i++) 
     try { 
      JSONObject obj = response.getJSONObject(i); 
      MyData myData = new MyData(); 
      myData.setContent_title(obj.getString("content_title")); 
      ... 
      ... 
      ... 
      ... 
      // adding content to array 
      homeList.add(myData); 
       } catch (JSONException e) { 
      e.printStackTrace(); 
     } 
    //Notifying the adapter that data has been added or changed 
    //this must always be called else the recycler would not understand when to stop or start working. 
    recyclerViewAdapter.notifyDataSetChanged(); 
    } 
12

So che la sua fine, ma spero vi aiuterà qualcuno. Sostituisci questi due metodi nell'adattatore.

@Override 
public long getItemId(int position) { 
    return position; 
} 

@Override 
public int getItemViewType(int position) { 
    return position; 
}