title: Issue with setting text to edittext inside Expandablelistview
body: <p>I am using edittext in every last child inside expandablelistview. Edittexts are visible only if its checkbox is selected. That is working fine but the problem is when I select a new lastchild, the previous edittext,s value gets copied to this. Also when I scroll, edittext values of each child gets interchanged giving me a lot of trouble. How to fix this? I tried many methods. Unfortunately none of them worked. I am posting the code of getchildView here. Also I dont have any problem when dealing with visibility of edittexts.   </p>
  
  <pre><code>public View getChildView(int groupPosition, int childPosition,
      boolean isLastChild, View convertView, ViewGroup parent) {
  
      final int groupPos=groupPosition;
      final int childPos=childPosition;
      final boolean islstchild=isLastChild;
      final Industries_Level_3 child = (Industries_Level_3) getChild(groupPosition, childPosition);
  
      if (convertView == null) {
  
          convertView = inflater.inflate(R.layout.multilevel_list_item_child, null);
      }
  
      final EditText edtOther=(EditText)convertView.findViewById(R.id.editIndOther);
  
  
  
      final CheckBox chkSelect=(CheckBox)convertView.findViewById(R.id.checkBoxInd);
      chkSelect.setText(child.getIndname());
  
      if(child.getSelected()!=null)
      {
      chkSelect.setChecked(child.getSelected());
  
      if (isLastChild) {
          if (child.getSelected()==true) {            
              edtOther.setVisibility(View.VISIBLE);
  
          } else {
              edtOther.setVisibility(View.GONE);
          }
      }else
      {
          edtOther.setVisibility(View.GONE);
      }
      }
  
      /*Setting text to edittext*/
      if(child.getOtherText()!=null)
      {
          if(child.getOtherText().length()&gt;0)
          {
              edtOther.setText(child.getOtherText().toString());
          }
      }
      chkSelect.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              if(chkSelect.isChecked())
              {
                  if(islstchild)
                  {
                      edtOther.setText("");
                      edtOther.setVisibility(View.VISIBLE);
                      edtOther.requestFocus();
  
                  }
                      grouplist.get(groupPos).getIndustry_Based_On_Group().get(childPos).setSelected(true);
                  notifyDataSetChanged();
  
                  if(!islstchild)
                  {
                      int count=0;
                      for (int i = 0; i &lt; grouplist.get(groupPos).getIndustry_Based_On_Group()
                          .size(); i++) {
                      if (grouplist.get(groupPos).getIndustry_Based_On_Group().get(i).getSelected()==true) {
  
                          if(i!=grouplist.get(groupPos).getIndustry_Based_On_Group().size()-1)
                          {
                          count = count + 1;
                          }
  
                          if (count == grouplist.get(groupPos).getIndustry_Based_On_Group().size()-1) {
                              grouplist.get(groupPos).setSelected(true);
                              notifyDataSetChanged();
                          }
                      }
  
                  }   
                  }
  
  
              }else
              {
                  if(!islstchild)
                  {
                  grouplist.get(groupPos).setSelected(false);
                  notifyDataSetChanged();
                  }else
                  {
                      edtOther.setText("");
                      child.setOtherText("");
                      edtOther.setVisibility(View.GONE);
  
                  }
                  grouplist.get(groupPos).getIndustry_Based_On_Group().get(childPos).setSelected(false);
                  notifyDataSetChanged();
  
              }
          }
      });
  
  
      edtOther.addTextChangedListener(new TextWatcher() {
  
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
              // TODO Auto-generated method stub
              String text= edtOther.getText().toString();
              child.setOtherText(text);
          }
  
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count,
                  int after) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void afterTextChanged(Editable s) {
              // TODO Auto-generated method stub
  
          }
      });
  
      return convertView;
  }  
  </code></pre>
  
  <p><strong>UPDATE: FULL CODE</strong> </p>
  
  <pre><code>public class IndBussinessAdapter extends BaseExpandableListAdapter{
  
  LayoutInflater inflater;
  
  /* list of group */
  private List&lt;IndustryGroup_Level_2&gt; grouplist;
  
  public IndBussinessAdapter(Context context,
          List&lt;IndustryGroup_Level_2&gt; bsgrouplist) {
      super();
      this.grouplist = bsgrouplist;
      inflater = (LayoutInflater) context
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }
  
  public long getChildId(int groupPosition, int childPosition) {
      return childPosition;
  }
  
  @Override
  public int getChildrenCount(int groupPosition) {
      List&lt;Industries_Level_3&gt; ch = grouplist.get(groupPosition)
              .getIndustry_Based_On_Group();
      return ch.size();
  }
  
  public View getChildView(int groupPosition, int childPosition,
      boolean isLastChild, View convertView, ViewGroup parent) {
  
      final int groupPos=groupPosition;
      final int childPos=childPosition;
      final boolean islstchild=isLastChild;
      final Industries_Level_3 child = (Industries_Level_3) getChild(groupPosition, childPosition);
  
      if (convertView == null) {
  
          convertView = inflater.inflate(R.layout.multilevel_list_item_child, null);
      }
  
      final EditText edtOther=(EditText)convertView.findViewById(R.id.editIndOther);
  
      /*Setting text to edittext*/
      if(child.getOtherText()!=null)
      {
          if(child.getOtherText().length()&gt;0)
          {
              edtOther.setText(child.getOtherText().toString());
          }
      }
  
      final CheckBox chkSelect=(CheckBox)convertView.findViewById(R.id.checkBoxInd);
      chkSelect.setText(child.getIndname());
  
      if(child.getSelected()!=null)
      {
      chkSelect.setChecked(child.getSelected());
  
      if (isLastChild) {
          if (child.getIndname().startsWith("Other") &amp;&amp; child.getSelected()==true) {          
              edtOther.setVisibility(View.VISIBLE);
              edtOther.requestFocus();
  
          } else {
              edtOther.setVisibility(View.GONE);
          }
      }else
      {
          edtOther.setVisibility(View.GONE);
      }
      }
  
      chkSelect.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              if(chkSelect.isChecked())
              {
                  if(islstchild)
                  {
  
                      edtOther.setVisibility(View.VISIBLE);
                      edtOther.requestFocus();
  
                  }
                  grouplist.get(groupPos).getIndustry_Based_On_Group().get(childPos).setSelected(true);
                  notifyDataSetChanged();
  
                  if(!islstchild)
                  {
                      int count=0;
                      for (int i = 0; i &lt; grouplist.get(groupPos).getIndustry_Based_On_Group()
                          .size(); i++) {
                      if (grouplist.get(groupPos).getIndustry_Based_On_Group().get(i).getSelected()==true) {
  
                          if(i!=grouplist.get(groupPos).getIndustry_Based_On_Group().size()-1)
                          {
                          count = count + 1;
                          }
  
                          if (count == grouplist.get(groupPos).getIndustry_Based_On_Group().size()-1) {
                              grouplist.get(groupPos).setSelected(true);
                              notifyDataSetChanged();
                          }
                      }
  
                  }   
                  }
  
  
              }else
              {
                  if(!islstchild)
                  {
                  grouplist.get(groupPos).setSelected(false);
                  notifyDataSetChanged();
                  }else
                  {
                      edtOther.setText("");
                      child.setOtherText("");
                      edtOther.setVisibility(View.GONE);
  
                  }
                  grouplist.get(groupPos).getIndustry_Based_On_Group().get(childPos).setSelected(false);
                  notifyDataSetChanged();
  
  
  
  
  
              }
          }
      });
  
  
      edtOther.addTextChangedListener(new TextWatcher() {
  
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
              // TODO Auto-generated method stub
              String text= edtOther.getText().toString();
              child.setOtherText(text);
          }
  
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count,
                  int after) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void afterTextChanged(Editable s) {
              // TODO Auto-generated method stub
  
          }
      });
  
      return convertView;
  }
  
  public IndustryGroup_Level_2 getGroup(int groupPosition) {
      return grouplist.get(groupPosition);
  }
  
  public int getGroupCount() {
      return grouplist.size();
  }
  
  public long getGroupId(int groupPosition) {
      return groupPosition;
  }
  
  public View getGroupView(int groupPosition, boolean isExpanded,
          View convertView, ViewGroup parent) {
      final int gpos=groupPosition;
  
      final IndustryGroup_Level_2 group = (IndustryGroup_Level_2) getGroup(groupPosition);
  
      if (convertView == null) {
          if (groupPosition==(grouplist.size())-1) {
              convertView = inflater.inflate(R.layout.multilevel_list_item2,
                      null);
          } else {
              convertView = inflater.inflate(R.layout.multilevel_list_item,
                      null);
          }
      }
      if (groupPosition==(grouplist.size())-1) {
          convertView = inflater.inflate(R.layout.multilevel_list_item2,
                  null);
      } else {
          convertView = inflater.inflate(R.layout.multilevel_list_item,
                  null);
      }
  
      TextView groupName = (TextView) convertView.findViewById(R.id.textListItem);
      groupName.setText(group.getIndgroupname());
      final CheckBox chkSelect=(CheckBox)convertView.findViewById(R.id.checkBoxInd);
      final EditText edtOther=(EditText)convertView.findViewById(R.id.editTextOtherGroup);
  
      if (gpos==grouplist.size()-1) {
  
          if (group.getSelected()) {
              edtOther.setVisibility(View.VISIBLE);
              edtOther.requestFocus();
  
          } else {
              edtOther.setText("");
              edtOther.setVisibility(View.GONE);
  
          }
  
      }else
      {
          edtOther.setText("");
          edtOther.setVisibility(View.GONE);
      }
  
      if(group.getSelected()!=null)
      {
      chkSelect.setChecked(group.getSelected());
      }
  
  
  
      chkSelect.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              System.out.println("Arraylist size "+grouplist.size());
              System.out.println("Group position "+gpos);
  
              if(chkSelect.isChecked())
              {
                  group.setSelected(true);
                  notifyDataSetChanged();
  
  
                  if(gpos!=grouplist.size()-1)
                  {
                  for(int i=0;i&lt;group.getIndustry_Based_On_Group().size();i++)
                  {
                      if(i!=group.getIndustry_Based_On_Group().size()-1)
                      {
                      group.getIndustry_Based_On_Group().get(i).setSelected(true);
                      notifyDataSetChanged();
                      }
                  }
                  }
              }else
              {
                  group.setSelected(false);
                  notifyDataSetChanged();
  
                  if(gpos!=grouplist.size()-1)
                  {
                  for(int i=0;i&lt;group.getIndustry_Based_On_Group().size();i++)
                  {
                      if(i!=group.getIndustry_Based_On_Group().size()-1)
                      {
                      group.getIndustry_Based_On_Group().get(i).setSelected(false);
                      notifyDataSetChanged();
                      }
                  }
                  }
              }
          }
      });
  
      if(group.getOtherText()!=null)
      {
          edtOther.setText(group.getOtherText());
      }
  
      edtOther.addTextChangedListener(new TextWatcher() {
  
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
              // TODO Auto-generated method stub
              String text=edtOther.getText().toString();
              group.setOtherText(text);
  
          }
  
          @Override
          public void beforeTextChanged(CharSequence s, int start, int count,
                  int after) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void afterTextChanged(Editable s) {
              // TODO Auto-generated method stub
  
          }
      });
  
      return convertView;
  }
  
  public boolean isChildSelectable(int groupPosition, int childPosition) {
      return true;
  }
  
  public boolean hasStableIds() {
      return true;
  }
  
  public Industries_Level_3 getChild(int groupPosition, int childPosition) {
      List&lt;Industries_Level_3&gt; ch = grouplist.get(groupPosition)
              .getIndustry_Based_On_Group();
      return ch.get(childPosition);
  }
  }
  </code></pre>