title: ExpandableListView item background color weird behavior
body: <p>I am trying to set background color when the user touch a child inside expandable list view. I managed to do this by using this code:</p>
  
  <pre><code>ArrayList&lt;ChildView&gt; childViewList;
  
  ExpandableListView expandablelistview_options = (ExpandableListView) view.findViewById(R.id.expandablelistview_options);
  
  expandablelistview_options.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
  
  @Override
  public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id)
  {
      int index = removeChildView(groupPosition);
      ArrayList&lt;ConciergeOptionsPairs&gt; children=data.Options.get(groupPosition).childrens;
  
      if (index != childPosition)
      {
          v.setBackgroundColor(ContextCompat.getColor(getActivity(),R.color.orange));
          v.invalidate();
          addChildView(new ChildView(groupPosition, childPosition, v, children.get(childPosition)));
      }
  
      return false;
  }
  });
  
  private int removeChildView(int groupPosition)
      {
          int index = 0;
          int childpos = 0;
          boolean exists = false;
          for (ChildView c : childViewList)
          {
              if (c.groupPosition == groupPosition)
              {
                  c.view.setBackgroundColor(ContextCompat.getColor(getActivity(),R.color.transparent));
                  c.view.invalidate();
                  childpos = c.childPosition;
                  exists = true;
                  break;
              }
              index++;
          }
  
          if (exists)
          {
              childViewList.remove(index);
              return childpos;
          }
  
          return -1;
      }
  
  private void addChildView(ChildView child)
  {
      childViewList.add(child);
  }
  </code></pre>
  
  <p>Everything works fine except from this weird behavior: </p>
  
  <p>I have 2 group Views, If I expand the second group, choose the second child and then expand the first group, the background of the first child of the first group get colored and the background of the child of the second group get transparent.</p>
  
  <p><a href="https://i.stack.imgur.com/bEyC0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bEyC0.png" alt="enter image description here"></a></p>
  
  <p>When I expand the first group without choosing any child :</p>
  
  <p><a href="https://i.stack.imgur.com/UFffA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UFffA.png" alt="enter image description here"></a></p>
  
  <p>If I collapse the first group, the background of the child of the second group get colored again.</p>
  
  <p>Here is my ExpandableListView adapter code:</p>
  
  <pre><code>public class ConciergeOptionsExpandableListAdapter extends BaseExpandableListAdapter
  {
      private Context context;
      private ArrayList&lt;ConciergeOptions&gt; data;
      private HotelStay hotelStay;
      private int lastExpandedGroupPosition;
  
      public ConciergeOptionsExpandableListAdapter(Context context, ArrayList&lt;ConciergeOptions&gt; data) {
          this.context = context;
          this.data = data;
          hotelStay=HotelStay.getInstance(context);
      }
  
      @Override
      public int getGroupCount() {
          return this.data.size();
      }
  
      @Override
      public Object getGroup(int groupPosition) {
          return this.data.get(groupPosition);
      }
  
      @Override
      public long getGroupId(int groupPosition) {
          return groupPosition;
      }
  
      @Override
      public View getGroupView(final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent)
      {
          ConciergeOptions options = (ConciergeOptions) getGroup(groupPosition);
  
          if (convertView == null) {
              LayoutInflater infalInflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = infalInflater.inflate(R.layout.concierge_options_item, null);
          }
  
          RelativeLayout container = (RelativeLayout) convertView.findViewById(R.id.container);
          TextView option_name = (TextView) convertView.findViewById(R.id.option_name);
          ImageView arrow = (ImageView) convertView.findViewById(R.id.arrow);
  
          option_name.setText(options.name);
  
          if(isExpanded){
              convertView.setBackgroundResource(R.color.bluebutton);
          }else{
              convertView.setBackgroundResource(R.color.transparent);
          }
  
          return convertView;
      }
  
      @Override
      public int getChildrenCount(int groupPosition) {
          return (this.data.get(groupPosition).childrens.size());
      }
  
  
      @Override
      public Object getChild(int groupPosition, int childPosititon) {
          ArrayList&lt;ConciergeOptionsPairs&gt; children=this.data.get(groupPosition).childrens;
          if(children!=null){
              return children.get(childPosititon);
          }
          return null;
      }
  
      @Override
      public long getChildId(int groupPosition, int childPosition) {
          return childPosition;
      }
  
  
      @Override
      public View getChildView(final int groupPosition, final int childPosition,
                               boolean isLastChild, View convertView, ViewGroup parent) {
  
          if (convertView == null) {
              LayoutInflater infalInflater = (LayoutInflater) this.context
                      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = infalInflater.inflate(R.layout.concierge_options_inner_items, null);
          }
  
          TextView option_type = (TextView) convertView.findViewById(R.id.option_type);
          TextView price = (TextView) convertView.findViewById(R.id.price);
          TextView decimal = (TextView) convertView.findViewById(R.id.decimal);
          TextView currency = (TextView) convertView.findViewById(R.id.currency);
  
          ConciergeOptionsPairs option_pair = (ConciergeOptionsPairs) getChild(groupPosition, childPosition);
          option_type.setText(option_pair.name);
  
          double t_price = Double.parseDouble(option_pair.value);
          double dec = t_price - (long) t_price;
          long decim = (long) dec;
  
          int decimal_int = (int) t_price;
  
          price.setText("+" + String.valueOf(decimal_int));
          decimal.setText("." + String.valueOf(decim));
          currency.setText("$");
  
          return convertView;
      }
  
      @Override
      public void notifyDataSetChanged() {
          super.notifyDataSetChanged();
      }
  
      @Override
      public boolean isChildSelectable(int groupPosition, int childPosition) {
          return true;
      }
  
      @Override
      public boolean hasStableIds() {
          return false;
      }
  }
  </code></pre>
  
  <p>Any idea how can I solve this problem?</p>