title: ExpandableListview with single as well as multiple selection
body: <p><a href="https://i.stack.imgur.com/FpLd2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FpLd2.jpg" alt="enter image description here"></a></p>
  
  <p>[Adapter class]</p>
  
  <p>public class CustomExpandableListAdapter extends BaseExpandableListAdapter {</p>
  
  <pre><code>private Context context;
  private List&lt;String&gt; expandableListTitle;
  private HashMap&lt;String, List&lt;FilterList&gt;&gt; expandableListDetail;
  private boolean checked;
  private int lastClickedPosition;
  
      private List&lt;Boolean&gt; setValueForSeletedFilter;
  private String[] keysOfHashmap;
  
  public CustomExpandableListAdapter(Context context, List&lt;String&gt; expandableListTitle,
                                     HashMap&lt;String, List&lt;FilterList&gt;&gt; expandableListDetail, List&lt;Boolean&gt; setValueForSeletedFilter) {
      this.context = context;
      this.expandableListTitle = expandableListTitle;
      this.expandableListDetail = expandableListDetail;
      this.setValueForSeletedFilter = setValueForSeletedFilter;
  
  }
  
  @Override
  public Object getChild(int listPosition, int expandedListPosition) {
      return this.expandableListDetail.get(this.expandableListTitle.get(listPosition))
              .get(expandedListPosition).getSearchFilterValue();
  }
  
  @Override
  public long getChildId(int listPosition, int expandedListPosition) {
      return expandedListPosition;
  }
  
  @Override
  public View getChildView(final int listPosition, final int expandedListPosition,
                           boolean isLastChild, View convertView, ViewGroup parent) {
  
      final String expandedListText = (String) getChild(listPosition, expandedListPosition);
      if (convertView == null) {
          int i = listPosition;
          int j = expandedListPosition;
  
          LayoutInflater layoutInflater = (LayoutInflater) this.context
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          convertView = layoutInflater.inflate(R.layout.list_item, null);
  
  
  
          TextView expandedListTextView = (TextView) convertView
                  .findViewById(R.id.expandedListItem);
          expandedListTextView.setText(expandedListText);
          String s = expandableListTitle.get(listPosition);
          final ImageView imageView = (ImageView) convertView.findViewById(R.id.iv_select);
  
          if (setValueForSeletedFilter.get(expandedListPosition) == true) {
              imageView.setVisibility(View.VISIBLE);
          } else {
              imageView.setVisibility(View.GONE);
          }
  
  
      }
      return convertView;
  }
  
  private void toggleSelection(int i, View v) {
      int j = i;
      ImageView imageView = (ImageView) v.findViewById(R.id.iv_select);
      imageView.setImageResource(R.drawable.ic_review);
  }
  
  @Override
  public int getChildrenCount(int listPosition) {
      return this.expandableListDetail.get(this.expandableListTitle.get(listPosition))
              .size();
  }
  
  @Override
  public Object getGroup(int listPosition) {
      return this.expandableListTitle.get(listPosition);
  }
  
  @Override
  public int getGroupCount() {
      return this.expandableListTitle.size();
  }
  
  @Override
  public long getGroupId(int listPosition) {
      return listPosition;
  }
  
  @Override
  public View getGroupView(int listPosition, boolean isExpanded,
                           View convertView, ViewGroup parent) {
      String listTitle = (String) getGroup(listPosition);
      if (convertView == null) {
          LayoutInflater layoutInflater = (LayoutInflater) this.context.
                  getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          convertView = layoutInflater.inflate(R.layout.list_group, null);
      }
      TextView listTitleTextView = (TextView) convertView
              .findViewById(R.id.listTitle);
      listTitleTextView.setTypeface(null, Typeface.BOLD);
      listTitleTextView.setText(listTitle);
      return convertView;
  }
  
  @Override
  public boolean hasStableIds() {
      return true;
  }
  
  public void setData(){
      notifyDataSetChanged();
  }
  
  @Override
  public boolean isChildSelectable(int listPosition, int expandedListPosition) {
      return true;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>[setting values for adapter class and notifying adapter on changing values]</p>
  
  <p>final HashMap> setValueForSeletedFilter = new HashMap&lt;>();
          String header = null;
          final List booleanList = new ArrayList&lt;>();
          final HashMap> stringListHashMap = new HashMap&lt;>();
          final List expandableListTitle;
          for (int i = 0; i &lt; filtersInfos.size(); i++) {
              stringListHashMap.put(filtersInfos.get(i).getFilterHeaderName(), filtersInfos.get(i).getFilterLists());</p>
  
  <pre><code>        if (filtersInfos.get(i).getFilterHeaderName().equalsIgnoreCase("Distance")) {
              header = filtersInfos.get(i).getFilterHeaderName();
              for (int j = 0; j &lt; filtersInfos.get(i).getFilterLists().size(); j++)
                  booleanList.add(false);
          }
      }
      setValueForSeletedFilter.put(header, booleanList);
  
  
      expandableListTitle = new ArrayList&lt;String&gt;(stringListHashMap.keySet());
      final CustomExpandableListAdapter adapter = new CustomExpandableListAdapter(this, expandableListTitle, stringListHashMap, booleanList);
      expandableListView.setAdapter(adapter);
      filterDialog.show();
  
      expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
  
          @Override
          public void onGroupExpand(int groupPosition) {
  
              Toast.makeText(getApplicationContext(),
                      expandableListTitle.get(groupPosition) + " List Expanded.",
                      Toast.LENGTH_SHORT).show();
          }
      });
  
      expandableListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
  
          @Override
          public void onGroupCollapse(int groupPosition) {
              Toast.makeText(getApplicationContext(),
                      expandableListTitle.get(groupPosition) + " List Collapsed.",
                      Toast.LENGTH_SHORT).show();
          }
      });
  
      final boolean[] checked = {false};
      final int[] lastClickedPosition = {0};
      expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
          @Override
          public boolean onChildClick(ExpandableListView parent, View v,
                                      int groupPosition, int childPosition, long id) {
  
              if (expandableListTitle.get(groupPosition).equalsIgnoreCase("Distance")) {
                  booleanList.add(childPosition, true);
                  setValueForSeletedFilter.put(expandableListTitle.get(groupPosition), booleanList);
                  expandableListView.setAdapter(adapter);
                  adapter.notifyDataSetChanged();
  
              }
  
              return false;
          }
      });
  
      close.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              filterDialog.dismiss();
          }
      });
      done.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
          }
      });
  }
  </code></pre>
  
  <p>on the basis of header make list single or multi selection android.</p>