title: Expandable listview recycling issue
body: <p>Friends, I am using an Expandable listview to display various categories and its subitems. I am using checkbox for selecting the subitems, so that multiple subitems can be selected from various categories. But here I am facing an issue due to the recycling of the views. When I expand the category and tick the checkbox of the subitems in it, then when I click on another category, some checkbox is already checked in it. I assume this is happening due to the recycling of views. I want to solve this issue. I have faced a similar issue with recyclerview also. Please guide me in this. Thank you in advance.
  I am pasting my adapter code for reference -</p>
  
  <pre><code> public class DayBookAdapter extends BaseExpandableListAdapter {
  
      private Context _context;
      private List&lt;DayBookData&gt; listDataHeader;
      String msubItem,mcategory;
      ArrayList&lt;String&gt;  selecteditems;
      ArrayList&lt;String&gt;  selectedcategories;
      public DayBookAdapter(Context context, List&lt;DayBookData&gt; listDataHeader, ArrayList&lt;String&gt; selectedItems,ArrayList&lt;String&gt; selectedcategories) {
          this._context = context;
          this.listDataHeader = listDataHeader;
          this.selecteditems = selectedItems;
          this.selectedcategories = selectedcategories;
      }
  
      @Override
      public ArrayList&lt;DayBookDetailsData&gt; getChild(int groupPosition, int childPosititon) {
          return this.listDataHeader.get(groupPosition).getCh_list();
      }
  
      @Override
      public long getChildId(int groupPosition, int childPosition) {
          return childPosition;
      }
  
      @SuppressLint("InflateParams")
      @Override
      public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
  
          final DayBookDetailsData childText = listDataHeader.get(groupPosition).getCh_list().get(childPosition);
          Boolean checkstatus = childText.isIschecked();
          Log.d("checkstatus", "getChildView: "+checkstatus);
          if (convertView == null) {
              LayoutInflater infalInflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = infalInflater.inflate(R.layout.day_book_details_data_item, null);
          }
  
          TextView item_txt_sub_cat_id = convertView.findViewById(R.id.item_id);
          item_txt_sub_cat_id.setText(childText.getItem_id());
  
          CheckBox item_txt_sub_cat_name = convertView.findViewById(R.id.item_name);
          item_txt_sub_cat_name.setText(childText.getItem_name());
  
          item_txt_sub_cat_name.setOnClickListener(new View.OnClickListener() {
  
  
              public void onClick(View v) {
                  final CheckBox cb = (CheckBox) v;
  
  
                  msubItem = listDataHeader.get(groupPosition).getCh_list().get(childPosition).getItem_id();
                  mcategory = listDataHeader.get(groupPosition).getCategory_id();
                  if (cb.isChecked()) {
  
                      childText.setIschecked(true);
                      selecteditems.add(msubItem);
                      selectedcategories.add(mcategory);
                      Log.d("itemschecked", "items -"+selecteditems+"categories-"+selectedcategories);
                  } else {
                      childText.setIschecked(false);
                      selecteditems.remove(msubItem);
                      selectedcategories.remove(mcategory);
                      Log.d("itemschecked", "items -"+selecteditems+"categories-"+selectedcategories);
                  }
              }
          });
          return convertView;
      }
  
      @Override
      public int getChildrenCount(int groupPosition) {
          return this.listDataHeader.get(groupPosition).getCh_list().size();
      }
  
      @Override
      public DayBookData getGroup(int groupPosition) {
          return this.listDataHeader.get(groupPosition);
      }
  
      @Override
      public int getGroupCount() {
          return this.listDataHeader.size();
      }
  
      @Override
      public long getGroupId(int groupPosition) {
          return groupPosition;
      }
  
      @SuppressLint("InflateParams")
      @Override
      public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
          DayBookData headerTitle = getGroup(groupPosition);
          if (convertView == null) {
              LayoutInflater infalInflater = (LayoutInflater) this._context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = infalInflater.inflate(R.layout.day_book_data_item, null);
          }
          TextView item_txt_category_id = convertView.findViewById(R.id.category_id);
          TextView item_txt_category_name = convertView.findViewById(R.id.category_name);
          item_txt_category_id.setText(headerTitle.getCategory_id());
          item_txt_category_name.setText(headerTitle.getCategory_name());
          return convertView;
      }
      @Override
      public boolean hasStableIds() {
          return false;
      }
      @Override
      public boolean isChildSelectable(int groupPosition, int childPosition) {
          return true;
      }
  }
  </code></pre>
  
  <p>Let me know if you need anything else .
  Thank you.</p>
  
  <p>Edited - 
  Here is my pojo file for subitems, can anyone tell me what changes is to be done?</p>
  
  <pre><code>public class DayBookDetailsData {
  
      private String item_name;
      private String item_id;
  
      public boolean isIschecked() {
          return ischecked;
      }
  
      public void setIschecked(boolean ischecked) {
          this.ischecked = ischecked;
      }
  
      boolean ischecked;
  
      public DayBookDetailsData(String item_name, String item_id,boolean ischecked) {
          this.item_name = item_name;
          this.item_id = item_id;
          this.ischecked = ischecked;
      }
  
      public String getItem_name() {
          return item_name;
      }
  
      public String getItem_id() {
          return item_id;
      }
  
  
  }
  </code></pre>
  
  <p>And here is my JSON parsing code,where i am setting the boolean value-</p>
  
  <pre><code>  bData.setCategory_id(jObjIn.getString("cat_id"));
                  bData.setCategory_name(jObjIn.getString("c_name"));
  
                  JSONArray jArrItemData = new JSONArray(jObjIn.getString("itemdata"));
  
                  for (int j = 0; j &lt; jArrItemData.length(); j++) {
  
                      JSONObject jObjItem = new JSONObject(jArrItemData.getString(j));
  
                      try {
  
                          String item_id = jObjItem.getString("id");
                          String item_name = jObjItem.getString("item");
                          Boolean checkstatus = false;
                          bData.getCh_list().add(new DayBookDetailsData(item_name, item_id,checkstatus));
                      } catch (JSONException e) {
                          e.printStackTrace();
                      }
                  }
  
                  listData.add(bData);
              }
  
              exp_listview.setAdapter(new DayBookAdapter(getActivity(), listData,selectedItems,selectedcategory));
  </code></pre>
  
  <p>I have updated the file as per your suggestion but it is not helping me .CAn you please tell me what is wrong with my code.</p>