title: how to set value of edittext with same id in different inflated linearlayout views?
body: <p>I have one main layout with one LinearLayout. In this LinearLayout I inflates multiple xml layouts that contain a form with multiple text fields(3 EditText) in it.  </p>
  
  <p>On first attempt I show only one form. There is button for adding more forms. Suppose If user clicks on <strong>"Add"</strong> button two times then user have three total forms. I successfully get all data of these three forms.  </p>
  
  <p>For doing this I am targeting the main layout <strong>"LinearLayout"</strong> and then counting its child. After counting its child I called child views of Main LinearLayout by its position and then get EditText data and save into a list. Then I moved this list to next page. Everything works fine till then. But if user comes back on previous page, all inflated layouts were gone. So, I count the size of list on resume and set the values what users wrote last time.  </p>
  
  <p>The problem is when I set the values of EditText according to its view position. Only last object(of list) value is shown in all inflated layouts. Means when for loop ends it sets last object value in all layouts. This is my method for setting  values against a view:  </p>
  
  <pre><code>private void addFormDataOnResume(LinearLayout viewForm,Traveller otherTraveller)
  {
      EditText dateOfBirthEt = (EditText)viewForm.findViewById(R.id.dateOfBirth);
  
      dateOfBirthEt.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              showDatePickerDialog(dateOfBirthEt);
          }
      });
  
      dateOfBirthEt.setText(otherTraveller.getOtherDateOfBirth());
  
      EditText firstNameET = (EditText)viewForm.findViewById(R.id.firstName);
      firstNameET.setText(otherTraveller.getOtherFirstName());
  
      EditText lastNameEt = (EditText)viewForm.findViewById(R.id.lastName);
      lastNameEt.setText(otherTraveller.getOtherLastName());
  }
  </code></pre>
  
  <p>My loop code:</p>
  
  <pre><code>int otherTraSize = otherTravellersData.size();
  //adultsForms is the main linear layout in which I am adding views
  for(k=0; k &lt; otherTraSize; k++)
  {
  addFormOnResume();//Function for adding form layout
  int viewPos = adultsForms.getChildCount();
  if(viewPos&gt;0)
  {  
  addFormDataOnResume(adultsForms.getChildAt(viewPos-1), otherTravellersData.get(k));
  }
  }
  </code></pre>
  
  <p>My FUnction for adding forms:</p>
  
  <pre><code>private void addFormOnResume()
  {
      LinearLayout viewForm = (LinearLayout)layoutInflater.inflate(R.layout.other_traveller_form, null );
              adultsForms.addView(viewForm);
  
  }
  </code></pre>
  
  <p>I debug my code, all data of list seems fine. Objects are in proper order with proper values.<br>
  Please help me why only last object value is set to all of the inflated forms.  </p>
  
  <p>Any help would be really appreciated......Thanks in Advance.</p>