title: Multiple click events on expandablelistview's group element
body: <p>I have two question about expandablelistview click events on groupView's (not child)</p>
  
  <ol>
  <li><p>When i have child in my GroupView, i'm able to get the groupPosition using below snippet</p>
  
  <p>expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {</p>
  
  <pre><code>    @Override
      public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
          Log.d("Clicked on item: ", ""+groupPosition);
          return false;
      }
  });
  </code></pre></li>
  </ol>
  
  <p>but when i don't have any child, <strong>Unfortunately 'MyApp' has stopped</strong> on mouse click. In this case, How to get the groupPosition?</p>
  
  <ol start="2">
  <li><p>I have two buttons in my expandablelistview's groupView layout. now i need to register two different click events for both the buttons. This groupView also didn't has child. I searched in SO thoroughly, but i got no clue on this.</p>
  
  <pre><code>    &lt;LinearLayout
          android:layout_below="@id/qtd_prc_cont"
          android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center"&gt;
          &lt;Textview
              android:layout_width="wrap_content" android:layout_height="wrap_content"  android:id="@+id/group_text" android:text="Group 1" /&gt;
          &lt;Button
              android:id="@+id/btn_reject"
              android:layout_width="90dp" android:layout_height="30dp" android:text="Reject" android:textAllCaps="false" android:background="@drawable/reject_button_styles"
              android:layout_marginRight="60dp" android:textColor="#a1a2a1" android:textSize="13dp"/&gt;
          &lt;Button
              android:id="@+id/btn_accept"
              android:layout_width="90dp" android:layout_height="30dp" android:text="Accept" android:textAllCaps="false" android:background="@drawable/button_radius"
              android:textColor="@color/colorWhite" android:textSize="13dp"/&gt;
      &lt;/LinearLayout&gt;
  </code></pre></li>
  </ol>
  
  <p>Here's my adapter class:</p>
  
  <pre><code>public class OfferedTrucksAdapter extends BaseExpandableListAdapter {
  private Context context;
  private ArrayList&lt;QuotedListGroup&gt; groups;
  
  public OfferedTrucksAdapter(Context context, ArrayList&lt;QuotedListGroup&gt; groups) {
      this.context = context;
      this.groups = groups;
  }
  
  @Override
  public Object getChild(int groupPosition, int childPosition) {
      ArrayList&lt;QuotedListItem&gt; chList = groups.get(groupPosition).getItems();
      return chList.get(childPosition);
  }
  
  @Override
  public long getChildId(int groupPosition, int childPosition) {
      return childPosition;
  }
  
  @Override
  public View getChildView(int groupPosition, int childPosition,
                           boolean isLastChild, View convertView, ViewGroup parent) {
  
      QuotedListItem child = (QuotedListItem) getChild(groupPosition, childPosition);
      if (convertView == null) {
          LayoutInflater infalInflater = (LayoutInflater) context
                  .getSystemService(context.LAYOUT_INFLATER_SERVICE);
          convertView = infalInflater.inflate(R.layout.activity_quoted_list_item, null);
      }
      TextView container_label = (TextView) convertView.findViewById(R.id.container);
      container_label.setText(child.getContainer());
  
      TextView truck_number = (TextView) convertView.findViewById(R.id.truck_number);
      truck_number.setText(child.getTruckNumber().toString());
  
      TextView truck_weight = (TextView) convertView.findViewById(R.id.truck_weight);
      truck_weight.setText(child.getTruckWeight().toString());
  
      return convertView;
  }
  
  @Override
  public int getChildrenCount(int groupPosition) {
      ArrayList&lt;QuotedListItem&gt; chList = groups.get(groupPosition).getItems();
      return chList.size();
  }
  
  @Override
  public Object getGroup(int groupPosition) {
      return groups.get(groupPosition);
  }
  
  @Override
  public int getGroupCount() {
      return groups.size();
  }
  
  @Override
  public long getGroupId(int groupPosition) {
      return groupPosition;
  }
  
  @Override
  public View getGroupView(int groupPosition, boolean isExpanded,
                           View convertView, ViewGroup parent) {
      QuotedListGroup group = (QuotedListGroup) getGroup(groupPosition);
      if (convertView == null) {
          LayoutInflater inf = (LayoutInflater) context
                  .getSystemService(context.LAYOUT_INFLATER_SERVICE);
          convertView = inf.inflate(R.layout.activity_offered_trucks_group, null);
      }
  
      if(groupPosition%2 == 0) {
          convertView.findViewById(R.id.offered_trucks_group).setVisibility(View.VISIBLE);
          convertView.findViewById(R.id.offered_price_group).setVisibility(View.GONE);
  
          TextView destination = (TextView) convertView.findViewById(R.id.offered_destination);
          destination.setText(group.getDestination());
  
          TextView trucks = (TextView) convertView.findViewById(R.id.offered_trucks);
          trucks.setText(group.getTrucks() + "");
  
          TextView date_label = (TextView) convertView.findViewById(R.id.offered_date_label);
          date_label.setText(group.getDateLabel().toString());
  
          TextView material = (TextView) convertView.findViewById(R.id.offered_material);
          material.setText(group.getMaterial().toString());
  
          TruckaroIconView see_hide_icon = (TruckaroIconView) convertView.findViewById(R.id.offered_see_hide_icon);
          TextView see_hide_label = (TextView) convertView.findViewById(R.id.offered_see_hide_label);
          if(isExpanded) {
              see_hide_label.setText("Hide Trucks");
              see_hide_icon.setRotation(180);
          } else {
              see_hide_label.setText("See Trucks");
              see_hide_icon.setRotation(0);
          }
      } else {
          convertView.findViewById(R.id.offered_trucks_group).setVisibility(View.GONE);
          convertView.findViewById(R.id.offered_price_group).setVisibility(View.VISIBLE);
  
          TextView offeredPrice = (TextView) convertView.findViewById(R.id.offered_price);
          offeredPrice.setText(group.getOfferedPrice());
  
          TextView quotedPrice = (TextView) convertView.findViewById(R.id.quoted_price);
          quotedPrice.setText(group.getQuotedPrice());
  
      }
      return convertView;
  }
  
  protected static class RowViewHolder {
      public Button buttonReject, buttonAccept;
  }
  
  @Override
  public boolean hasStableIds() {
      return true;
  }
  
  @Override
  public boolean isChildSelectable(int groupPosition, int childPosition) {
      return true;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Based on accept/reject button clicks, i need to pass the Textview's data to next activity through intent.</p>
  
  <p>Here is how my expandable listview looks like: 
  <a href="https://i.stack.imgur.com/lZO1c.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lZO1c.png" alt="enter image description here"></a></p>
  
  <p>In the above image, there are four list items. 1st and 3rd have children but 2nd and 4th has no child. When i click on 2nd element accept button, i need to pass the 1st elemnt data to next activity. I'm unable to set click events on those buttons.</p>
  
  <p>Please help me out of this.</p>
  
  <p>Thanks in advance.</p>