title: expandable listview child click event
body: <p>I am using following layout for child row of expandable listview</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="55dip"
      android:orientation="vertical" &gt;
  
      &lt;RelativeLayout
          android:id="@+id/relativeItem"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" &gt;
  
          &lt;TextView
              android:id="@+id/labourheader"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentLeft="true"
              android:layout_centerVertical="true"
              android:layout_marginLeft="10dp"
              android:paddingBottom="5dp"
              android:textColor="#000000"
              android:textSize="17dip" /&gt;
  
          &lt;TextView
              android:id="@+id/labourrating"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_centerHorizontal="true"
              android:layout_centerVertical="true"
              android:layout_marginLeft="10dp"
              android:paddingBottom="5dp"
              android:textColor="#000000"
              android:textSize="17dip" /&gt;
  
          &lt;Button
              android:id="@+id/addtasks"
              android:layout_width="30dp"
              android:layout_height="20dp"
              android:layout_alignParentRight="true"
              android:layout_centerVertical="true"
              android:layout_marginRight="5dp"
              android:background="@drawable/plussquare"
              android:textColor="#000000"
              android:focusable="false"
              android:textSize="17dip" /&gt;
  
          &lt;Button
              android:id="@+id/showtaskbtn"
              android:layout_width="90dp"
              android:layout_height="30dp"
              android:layout_centerVertical="true"
              android:layout_toLeftOf="@id/addtasks"
              android:textColor="#000000"
              android:textSize="17dip" /&gt;
      &lt;/RelativeLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I want to add click listener for  ADDTASK and  showtask button.and want to get position of header and child position.after that i want to pas this values to another activity.
  i tried but its not giving me the proper positions on click listenr of buttons</p>
  
  <p>following is code of ADAPTER</p>
  
  <pre><code>public class ListAdapterforTask extends BaseExpandableListAdapter {
  
      private Context _context;
      private List&lt;CategoryDetail&gt; _listDataHeader;
      private HashMap&lt;CategoryDetail, List&lt;LabourDetail&gt;&gt; _listDataChild;
      LabourDetail b = new LabourDetail();
  
      public ListAdapterforTask(Context context,
              List&lt;CategoryDetail&gt; listDataHeader,
              HashMap&lt;CategoryDetail, List&lt;LabourDetail&gt;&gt; listChildData) {
          this._context = context;
          this._listDataHeader = listDataHeader;// category name
          this._listDataChild = listChildData;// labor name
  
      }
  
      @Override
      public Object getChild(int groupPosition, int childPosititon) {
          return this._listDataChild.get(this._listDataHeader.get(groupPosition))
                  .get(childPosititon);
      }
  
      @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) {
          try {
  
              if (convertView == null) {
                  LayoutInflater infalInflater = (LayoutInflater) this._context
                          .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  convertView = infalInflater.inflate(R.layout.task_child, null);
              }
  
              b = _listDataChild.get(_listDataHeader.get(groupPosition)).get(
                      childPosition);
  
              TextView txtLabourname = (TextView) convertView
                      .findViewById(R.id.labourheader);
              TextView txtLaborrate = (TextView) convertView
                      .findViewById(R.id.labourrating);
              Button buttonAdd = (Button) convertView.findViewById(R.id.addtasks);
  
              Button btnshowtask = (Button) convertView
                      .findViewById(R.id.showtaskbtn);
  
              btnshowtask.setVisibility(View.GONE);
              txtLabourname.setText(b.getcFirst_name() + "(" + b.getcLabor_id()
                      + ")");
  
              AddTaskToDb add = new AddTaskToDbImpl();
  
              List&lt;TaskDetail&gt; listtask = add.findByLabourid(Integer.parseInt(b
                      .getcLabor_id()));
  
              for (int i = 0; i &lt; listtask.size(); i++) {
                  btnshowtask.setVisibility(View.VISIBLE);
  
                  String firstTask = listtask.get(0).getcTask_Name();
  
                  btnshowtask.setText(firstTask);
  
              }
  
              btnshowtask.setOnClickListener(new OnClickListener() {
                  @Override
                  public void onClick(View v) {
  //                  LabourDetail b = listDataChild.get(
  //                          categoryList.get(groupPosition)).get(childPosition);
  //
  //                  Intent i = new Intent(TaskAssigmentActivity.this,
  //                          TaskActivity.class);
  //                  i.putExtra("catid", b.getcCategory_id());
  //                  i.putExtra("labid", b.getcLabor_id());
  //                  startActivity(i);
                  }
              });
  
              // String ratingstr=String.valueOf(b.getcRating());
              //
              // int rating=Integer.valueOf(ratingstr);
  
              txtLaborrate.setText(b.getcRating() + "");
  
              buttonAdd.setOnClickListener(new OnClickListener() {
                  @Override
                  public void onClick(View v) {
  
  
  
  
                  //  int position=(Integer)v.getTag();
                      //b = _listDataChild.get(_listDataHeader.get(groupPosition)).get(
                      //      position);
  
                      Intent i = new Intent(_context, TaskActivity.class);
                      i.putExtra("catid", b.getcCategory_id());
                      i.putExtra("labid", b.getcLabor_id());
                      _context.startActivity(i);
                  }
              });
  
          } catch (Exception e) {
          }
  
          return convertView;
      }
  
      @Override
      public int getChildrenCount(int groupPosition) {
          return this._listDataChild.get(this._listDataHeader.get(groupPosition))
                  .size();
      }
  
      @Override
      public Object getGroup(int groupPosition) {
          return this._listDataHeader.get(groupPosition);
      }
  
      @Override
      public int getGroupCount() {
          return this._listDataHeader.size();
      }
  
      @Override
      public long getGroupId(int groupPosition) {
          return groupPosition;
      }
  
      @Override
      public View getGroupView(int groupPosition, boolean isExpanded,
              View convertView, ViewGroup parent) {
          if (convertView == null) {
              LayoutInflater infalInflater = (LayoutInflater) this._context
                      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              convertView = infalInflater.inflate(R.layout.task_assign_group,
                      null);
          }
  
          TextView lblListHeader = (TextView) convertView
                  .findViewById(R.id.lblListHeader);
          TextView lbllabournum = (TextView) convertView
                  .findViewById(R.id.labourNumberabsent);
  
          List&lt;LabourDetail&gt; list = _listDataChild.get(_listDataHeader
                  .get(groupPosition));
  
          int count = list.size();
          String counter = String.valueOf(count);
          lbllabournum.setText(counter);
  
          lblListHeader.setTypeface(null, Typeface.BOLD);
  
          lblListHeader.setText(_listDataHeader.get(groupPosition)
                  .getcCategory_Name());
  
          return convertView;
      }
  
      @Override
      public boolean hasStableIds() {
          return false;
      }
  
      @Override
      public boolean isChildSelectable(int groupPosition, int childPosition) {
          return true;
      }
  
  }
  </code></pre>