I have created a RecyclerView with alternating row color like this:

[![enter image description here](https://i.stack.imgur.com/mMc3I.jpg)](https://i.stack.imgur.com/mMc3I.jpg)

Whenever I delete an row from the list say for example I delete row whose product name is `cookies` my list gets updated like this:

[![enter image description here](https://i.stack.imgur.com/flvuF.jpg)](https://i.stack.imgur.com/flvuF.jpg)

as you can see the updated list no longer supports alternating row color. The simple solution would be to change the background color of next View (row) after deleting the current View. For that I first need a reference of next View but as a beginner in android I don't know how to get it.

***Adapter:***

```
public class Adapter extends RecyclerView.Adapter<Adapter.ViewHolder>{

    private List<Model> originalList;

    Adapter(List<Model> list){ originalList = list; }

    @Override
    public void onBindViewHolder(final Adapter.ViewHolder holder, final int position) {

        Model list = originalList.get(position);

        if (position % 2 == 1)
            holder.itemView.setBackgroundColor(Color.parseColor("#e9e9e9"));

        final View holder.nextItemView = ? // how to get reference to next View here  

        holder.product.setText(list.getName());
        holder.price.setText(String.valueOf(list.getPrice()));
        holder.quantity.setText(String.valueOf(list.getQuantity()));            
        holder.options.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showPopupMenu(holder.options, nextItemView, position);
            }
        });
    }

    private void showPopupMenu(View options, final View view, final int position){
        final PopupMenu popup = new PopupMenu(options.getContext(), options);
        MenuInflater inflater = popup.getMenuInflater();
        inflater.inflate(R.menu.options_menu, popup.getMenu());
        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                String menuItem = item.toString();
                if (menuItem.equals("Delete")){                  
                     originalList.remove(position);
                     notifyItemRemoved(position);
                     int count = originalList.size();
                     if (count != 0){
                           int color = Color.TRANSPARENT;
                           Drawable background = view.getBackground();
                           if (background instanceof ColorDrawable)
                               color = ((ColorDrawable) background).getColor();         
                           if (color == Color.parseColor(#e9e9e9))
                              color = Color.TRANSPARENT;

                           view.setBackground(color); 
                     }  
                }
                return true;
            }
        });
        popup.show();
    }
}    

```

`options` is a `ImageButton` on the click of which I show a popup menu with item labelled as `Delete` on click of which the row gets deleted from the list.