title: Android RecyclerView -Multiple Edittext change simultaneously
body: <p>I have a <code>RecyclerView</code> that has many cards that hold 4 <code>EditText</code>. When I input values in one <code>EditText</code> of one card, it fills the same value in random cards. Surprisingly it does not jump <code>EditText</code>s for example:</p>
  
  <p>If I input values in <code>edittext1</code> of <code>card1</code> it would fill the same value into <code>edittext1</code> in <code>card8</code> and if I change the value in <code>card8</code> it will change the value back in <code>card1</code>. Could someone please tell me why this is happening.</p>
  
  <p>Thank You in Advance</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class MyAdapter extends RecyclerView.Adapter&lt;MyAdapter.ViewHolder&gt; {    
  private String[] mDataset;
  public String[][] data = new String[30][4];
  
  
  public static class ViewHolder extends RecyclerView.ViewHolder {
       // each data item is just a string in this case
       public LinearLayout mCardView;
  
       public ViewHolder(LinearLayout v) {
          super(v);
          mCardView = v;
      }
  }
  
  // Provide a suitable constructor (depends on the kind of dataset)
  public MyAdapter(String[] myDataset) {
      mDataset = myDataset;
  }
  
  // Create new views (invoked by the layout manager)
  @Override
  public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
                                                 int viewType) {
  
      LinearLayout v = (LinearLayout) LayoutInflater.from(parent.getContext())
              .inflate(R.layout.cards, parent, false);
  
      ViewHolder vh = new ViewHolder(v);
      return vh;
  }
  
  
  // Replace the contents of a view (invoked by the layout manager)
  @Override
  public void onBindViewHolder(ViewHolder holder, final int position) {
      // - get element from your dataset at this position
      // - replace the contents of the view with that element
      final EditText txt = (EditText) holder.mCardView.findViewById(R.id.ip1_text);
      final EditText txt2 = (EditText) holder.mCardView.findViewById(R.id.ip2_text);
  
      final EditText txt3 = (EditText) holder.mCardView.findViewById(R.id.ip3_text);
      final EditText txt4 = (EditText) holder.mCardView.findViewById(R.id.ip4_text);
      txt.addTextChangedListener(new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  
          }
  
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
  
          }
  
          @Override
          public void afterTextChanged(Editable s) {
              data[position][0] = s.toString();
              Log.d("DATA" + position + "0", s.toString());
          }
      });
      txt2.addTextChangedListener(new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  
          }
  
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
  
          }
  
          @Override
          public void afterTextChanged(Editable s) {
              data[position][1] = s.toString();
              Log.d("DATA" + position + "1", s.toString());
          }
      });
      txt3.addTextChangedListener(new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  
          }
  
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
  
          }
  
          @Override
          public void afterTextChanged(Editable s) {
              data[position][2] = s.toString();
              Log.d("DATA" + position + "2", s.toString());
          }
      });
      txt4.addTextChangedListener(new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  
          }
  
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
  
          }
  
          @Override
          public void afterTextChanged(Editable s) {
              data[position][3] = s.toString();
              Log.d("DATA" + position + "3", s.toString());
          }
      });
  
      TextView t = (TextView) holder.mCardView.findViewById(R.id.serNo);
      t.setText(mDataset[position]);
  
  
  }
  
  // Return the size of your dataset (invoked by the layout manager)
  @Override
  public int getItemCount() {
      return mDataset.length;
  }
  
  public String[][] getData() {
      return data;
  }  
  </code></pre>
  
  <p>And this is my card xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:card_view="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:orientation="vertical"
  android:weightSum="1"&gt;
  &lt;!-- A CardView that contains a TextView --&gt;
  &lt;android.support.v7.widget.CardView
      android:id="@+id/card_view"
      android:layout_width="375dp"
      android:layout_height="wrap_content"
      android:layout_margin="4dp"
      android:backgroundTint="#eeeeee"
      card_view:cardCornerRadius="4dp"&gt;
  
      &lt;TextView
          android:id="@+id/serNo"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center_vertical"
          android:text="number"
          android:layout_margin="20dp"
          android:textColor="@color/cardview_dark_background" /&gt;
  
      &lt;RelativeLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center"&gt;
  
          &lt;EditText
              android:id="@+id/ip1_text"
              android:layout_width="100dp"
              android:layout_height="30dp"
              android:layout_alignParentLeft="true"
              android:layout_marginTop="20dp"
              android:background="@color/cardview_light_background"
              android:inputType="number"
              android:maxLength="2" /&gt;
  
          &lt;EditText
              android:id="@+id/ip3_text"
              android:layout_width="80dp"
              android:layout_height="30dp"
              android:layout_below="@+id/ip1_text"
              android:layout_marginBottom="10dp"
              android:layout_marginLeft="10dp"
              android:layout_marginTop="10dp"
              android:background="@color/cardview_light_background"
              android:inputType="number"
              android:maxLength="1" /&gt;
  
          &lt;EditText
              android:id="@+id/ip2_text"
              android:layout_width="100dp"
              android:layout_height="30dp"
              android:layout_marginLeft="20dp"
              android:layout_marginTop="20dp"
              android:layout_toRightOf="@+id/ip1_text"
              android:background="@color/cardview_light_background"
              android:inputType="number"
              android:maxLength="2" /&gt;
  
          &lt;EditText
              android:id="@+id/ip4_text"
              android:layout_width="80dp"
              android:layout_height="30dp"
              android:layout_below="@+id/ip2_text"
              android:layout_marginBottom="10dp"
              android:layout_marginLeft="40dp"
              android:layout_marginTop="10dp"
              android:layout_toRightOf="@+id/ip3_text"
              android:background="@color/cardview_light_background"
              android:inputType="number"
              android:maxLength="1" /&gt;
      &lt;/RelativeLayout&gt;
  &lt;/android.support.v7.widget.CardView&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/PM5Ca.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PM5Ca.png" alt="Added to card one"></a></p>
  
  <p><a href="https://i.stack.imgur.com/QqCjP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QqCjP.png" alt="Automatically it also appears in card 10"></a></p>