title: Chronometer in RecyclerView : Timer became 00:00:00 when scrolling
body: <p>I following this <a href="http://abhiandroid.com/ui/chronometer" rel="nofollow noreferrer">1</a> ,<a href="https://stackoverflow.com/questions/526524/android-get-time-of-chronometer-widget">2</a> an this <a href="https://developer.android.com/reference/android/widget/Chronometer.html" rel="nofollow noreferrer">3</a> . I have an <code>RecyclerView</code> with <code>CardView</code>. I have add an timer using <code>Chronometer</code>. The aplication work like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Dllg0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dllg0.png" alt="enter image description here"></a></p>
  
  <p>There is first condition of <code>CardView</code> with Green Color. When User choose one, the color of change into Yellow. </p>
  
  <p>I want make if the timer in 00:30:00(HH:MM:SS) the Color of <code>CardView</code> change color again into Blue. And when the timer in 01:00:00(HH:MM:SS), the color of <code>CardView</code> change again into Brown. </p>
  
  <p>I following that tutor(above) But when i scroll down the <code>RecyclerView</code> , the timer (Choronometer) is became 00:00:00 again . I dont know where is the wrong.</p>
  
  <p>Activity.java </p>
  
  <pre><code>private static final int THIRTYMINUTES = 1800000;
  private static final int HOUR = 3600000;
  
  int h,m,s;
  
  ...........
  ...........
  
  @Override
          public void OnRecyclerViewItemBind(final Adapter.ViewHolder holder, final int position) {
              holder.txt_time_occ.setBase(SystemClock.elapsedRealtime());
  
              try {
                  JSONObject currTable = filteredTableList.getJSONObject(position);
  
                  holder.txt_no_table.setText(currTable.getString("tischnr"));
                  holder.txt_no_table_occ.setText(currTable.getString("tischnr"));
                  holder.txt_guest_name_occ.setText("");
                  holder.txt_pax_occ.setText("");
                  holder.txt_bill_occ.setText("");
  
                  holder.txt_time_occ.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener(){
                      @Override
                      public void onChronometerTick(Chronometer cArg) {
                          long time = SystemClock.elapsedRealtime() - cArg.getBase();
                          h = (int)(time /3600000);
                          m = (int)(time - h*3600000)/60000;
                          s = (int)(time - h*3600000 - m*60000)/1000 ;
                          String hh = h &lt; 10 ? "0"+h: h+"";
                          String mm = m &lt; 10 ? "0"+m: m+"";
                          String ss = s &lt; 10 ? "0"+s: s+"";
                          cArg.setText(hh+":"+mm+":"+ss);
                          holder.txt_time_occ.setText(String.format("%02d:%02d:%02d", h, m, s));
  
                          if (time &gt; t1){
                              holder.itemView.setBackgroundResource(R.color.colorBrownTableOcc_3);
                              holder.title_layout.setBackgroundResource(R.color.colorBrownTableOcc_4);
                          }
  
                          if (time &gt; t2) {
                              holder.itemView.setBackgroundResource(R.color.colorRedTableOcc);
                              holder.title_layout.setBackgroundResource(R.color.colorDeepRedTableOcc);
                          }
                      }
                  });
  
  
                  int queasy33Index = ProgramMethod.getJSONArrayIndex(queasy33List,"number2", currTable.getInt("tischnr"));
                  if (queasy33Index &gt;= 0) {
                      holder.txt_guest_name_occ.setText(queasy33List.getJSONObject(queasy33Index).getString("char2"));
                      holder.txt_pax_occ.setText(queasy33List.getJSONObject(queasy33Index).getString("number3"));
                  }
  
                  int billIndex = ProgramMethod.getJSONArrayIndex(billList, "tischnr", currTable.getInt("tischnr"));
                  if(billIndex &gt;= 0) {
                  holder.txt_bill_occ.setText(billList.getJSONObject(billIndex).getString("saldo"));
                  }
  
                  if (currTable.has("selected") &amp;&amp; currTable.getBoolean("selected")) {
                      holder.itemView.setBackgroundResource(R.color.colorYellowTableOcc_6);
                      holder.title_layout.setBackgroundResource(R.color.colorYellowTableOcc_7);
                      holder.txt_time_occ.setBase(SystemClock.elapsedRealtime());
                      holder.txt_time_occ.start();
                      holder.txt_no_table.setVisibility(View.INVISIBLE);
                      holder.txt_no_table_occ.setVisibility(View.VISIBLE);
                      holder.txt_bill_occ.setVisibility(View.VISIBLE);
                      holder.txt_pax_occ.setVisibility(View.VISIBLE);
                      holder.txt_time_occ.setVisibility(View.VISIBLE);
                      holder.txt_guest_name_occ.setVisibility(View.VISIBLE);
                      holder.cardview_table.setCardElevation(24);
  
                  } else {
                      holder.txt_time_occ.stop();
                      holder.txt_time_occ.setBase(SystemClock.elapsedRealtime());
                      holder.itemView.setBackgroundResource(R.color.colorTableGreen);
                      holder.title_layout.setBackgroundResource(R.color.colorTableGreen);
                      holder.txt_no_table.setVisibility(View.VISIBLE);
                      holder.txt_no_table_occ.setVisibility(View.INVISIBLE);
                      holder.txt_bill_occ.setVisibility(View.INVISIBLE);
                      holder.txt_pax_occ.setVisibility(View.INVISIBLE);
                      holder.txt_time_occ.setVisibility(View.INVISIBLE);
                      holder.txt_guest_name_occ.setVisibility(View.INVISIBLE);
                      holder.cardview_table.setCardElevation(1);
                  }
  
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
  
          @Override
          public int OnRecyclerViewItemCount() {
              return filteredTableList.length();
          }
      });
  }
  </code></pre>
  
  <p>Adapter.java</p>
  
  <pre><code>public class Adapter extends RecyclerView.Adapter&lt;Adapter.ViewHolder&gt; {
  
  public static final int view1 = 0;
  public static final int view2 = 1;
  
  private static OnRecyclerViewItemClickedListener recyclerViewItemClickedListener;
  
  public void setOnRecyclerViewClickedListener (OnRecyclerViewItemClickedListener l) {
      recyclerViewItemClickedListener = l;
  }
  
  public interface OnRecyclerViewItemClickedListener {
      void OnRecyclerViewItemClicked(int position);
      void OnRecyclerViewItemBind(ViewHolder holder, int position);
      int OnRecyclerViewItemCount();
  }
  
  public Adapter() {
      super();
  }
  
  
  @Override
  public Adapter.ViewHolder onCreateViewHolder(final ViewGroup parent, int viewType) {
  
  
  
      View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.table_item_empty, parent, false);
      return new ViewHolder(v);
  }
  
  @Override
  public void onBindViewHolder(ViewHolder holder, int position) {
      recyclerViewItemClickedListener.OnRecyclerViewItemBind(holder, position);
  }
  
  @Override
  public int getItemCount() {
      return recyclerViewItemClickedListener.OnRecyclerViewItemCount();
  }
  
  
  public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
      public TextView txt_no_table;
      public TextView txt_no_table_occ;
      public TextView txt_pax_occ;
      public TextView txt_guest_name_occ;
      public TextView txt_bill_occ;
      public Chronometer txt_time_occ;
      public CardView cardview_table;
  
  
  
      public ViewHolder(View itemView) {
          super(itemView);
          itemView.setOnClickListener(this);
  
          txt_no_table = (TextView) itemView.findViewById(R.id.txt_no_table_empty);
          txt_no_table_occ = (TextView) itemView.findViewById(R.id.txt_no_table);
          txt_pax_occ = (TextView) itemView.findViewById(R.id.txt_pax);
          txt_guest_name_occ = (TextView)itemView.findViewById(R.id.txt_guestname);
          txt_bill_occ = (TextView) itemView.findViewById(R.id.txt_bill);
          txt_time_occ = (Chronometer) itemView.findViewById(R.id.txt_time);
          cardview_table = (CardView) itemView.findViewById(R.id.table_card_empty);
      }
  
      @Override
      public void onClick(View itemView) {
          recyclerViewItemClickedListener.OnRecyclerViewItemClicked(getAdapterPosition());
     }
  }
  </code></pre>
  
  <p>Any answer will helpful for me. Thanks before</p>