title: How to do RecyclerView scroll save
body: <p>I have a recyclerView. Values are lost when recycler is scrolled down.I would like to have values greater than 7. Values come up when first opened but When I go down the scroll bar, it returns to its original state.</p>
  
  <p>FragmentB.java</p>
  
  <pre><code>public class FragmentB extends  Fragment{
  View view ;
  TextView textView;
  RecyclerView recyclerView ;
  ArrayList&lt;OnemliDepremler&gt; onemliDepremler;
  BuyukRecyclerAdapter buyukRecyclerAdapter;
  
  
  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
  
      view = inflater.inflate(R.layout.fragment_sabit,container,false);
      // textView=view.findViewById(R.id.textView3);
  
      recyclerView = view.findViewById(R.id.recyclerView);
      LinearLayoutManager layoutManager=new LinearLayoutManager(getActivity());
      layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
      layoutManager.scrollToPosition(0);
      recyclerView.setLayoutManager(layoutManager);
      onemliDepremler=new ArrayList&lt;OnemliDepremler&gt;();
  
  
  
  
      Factory.getInstance().buyukDepremModel().enqueue(new Callback&lt;OnemliDepremModel&gt;() {
          @Override
          public void onResponse(Call&lt;OnemliDepremModel&gt; call, Response&lt;OnemliDepremModel&gt; response) {
  
              buyukRecyclerAdapter=new BuyukRecyclerAdapter(response.body().data.subList(0, 10));
              recyclerView.setAdapter(buyukRecyclerAdapter);
          }
  
          @Override
          public void onFailure(Call&lt;OnemliDepremModel&gt; call, Throwable t) {
  
          }
      });
  
  
  
      return view;
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>BuyukRecyclerAdapter.java</p>
  
  <pre><code> public class BuyukRecyclerAdapter extends RecyclerView.Adapter&lt;BuyukRecyclerAdapter.ViewHolder&gt; {
  
  public static class ViewHolder extends RecyclerView.ViewHolder{
      public TextView buyukluk;
      public TextView yer;
      public TextView tarih;
      public CardView cardView ;
      FrameLayout frameLayout;
  
      public ViewHolder(View itemView) {
          super(itemView);
          cardView = itemView.findViewById(R.id.card_view);
          buyukluk=itemView.findViewById(R.id.text_buyukluk);
          yer=itemView.findViewById(R.id.text_yer);
          tarih=itemView.findViewById(R.id.text_tarih);
          frameLayout=itemView.findViewById(R.id.frame_layout);
      }
  }
  List&lt;Datum&gt; onemliDepremler;
  
  public BuyukRecyclerAdapter(List&lt;Datum&gt; onemliDepremler) {
      this.onemliDepremler = onemliDepremler;
  }
  
  @Override
  public BuyukRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View v= LayoutInflater.from(parent.getContext()).inflate(R.layout.onemli_custom,parent,false);
      final ViewHolder view_holder=new ViewHolder(v);
      return view_holder;
  }
  
  @Override
  public void onBindViewHolder(ViewHolder holder, int position) {
      holder.buyukluk.setText(onemliDepremler.get(position).siddeti);
      holder.tarih.setText("Tarih  :"+onemliDepremler.get(position).tarih);
      holder.yer.setText(onemliDepremler.get(position).lokasyon);
  
      if(Float.parseFloat(onemliDepremler.get(position).siddeti)&gt;7){
          holder.frameLayout.setBackgroundColor(Color.RED);
      }
  
  
  }
  
  @Override
  public int getItemCount() {
      return onemliDepremler.size();
  }
  @Override
  public void onAttachedToRecyclerView(RecyclerView recyclerView) {
      super.onAttachedToRecyclerView(recyclerView);
  }
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/wnV3A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wnV3A.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/VZ1fs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VZ1fs.png" alt="enter image description here"></a></p>
  
  <p>Your advice important for me </p>
  
  <p>Thank you very much ! </p>