title: How to get onChildClick value from expandablelistview in android?
body: <p>I am working on a project with parsing JSON from url to ExpandableListView. Depending on the "status" tag value (active or pending) , will be placing records accordingly to to different groups "Active" and "Pending". Everything is working fine. </p>
  
  <p>My Problem is when I click on a child inside the second group which should show different data, but I am getting data the data from first group child.</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  import android.app.ExpandableListActivity;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.ExpandableListView;
  import android.widget.ListView;
  import android.widget.SimpleExpandableListAdapter;
  import android.widget.TextView;
  import android.widget.Toast;
  import android.widget.ExpandableListView.OnGroupClickListener;
  
  public class ExpandableActivity1 extends ExpandableListActivity {
      JSONArray jArray = null;
      JSONObject json_data = null;
      TextView txtMLSID;
          List&lt;Map&lt;String, String&gt;&gt; child1;
       List&lt;Map&lt;String, String&gt;&gt; child2;
  
         @Override
         public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
  
  
  
      List&lt;Map&lt;String, String&gt;&gt; groups = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
      Map&lt;String, String&gt; group1 = new HashMap&lt;String, String&gt;();
      group1.put("group", " Active");
      groups.add(group1);
      Map&lt;String, String&gt; group2 = new HashMap&lt;String, String&gt;();
      group2.put("group", " Pending");
      groups.add(group2);
      child1 = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
      child2 = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
  
  
  
  
      String url ="http://stage.realtylog.net/iPhone/functions.php?username=hussain16&amp;act=listing";
  
      String  json = JSONfunctions.getJSONfromURL(url);
  
  
  
  
   try{
  
  
  
  
   jArray = new JSONArray(json);
  
   for(int i=0;i&lt;jArray.length() ;i++){                       
  
  
       Map&lt;String, String&gt; childdata1 = new HashMap&lt;String, String&gt;();
  
          JSONObject e = jArray.getJSONObject(i);
  
          String status = e.getString("2");
           Log.e("log_tag","Status: "+status); 
  
           if (status.contains("active")){
               Log.e("log_tag","StatusActive: "+status); 
  
               childdata1.put("0",  String.valueOf(i+1)+" "+ e.getString("mlsid"));
  
  
  
                  child1.add(childdata1); 
  
           }else if(status.contains("pending")){
               Log.e("log_tag","StatusPending: "+status); 
  
  
  
                  Map&lt;String, String&gt; childdata2= new HashMap&lt;String, String&gt;();
                  childdata2.put("0",  String.valueOf(i+1)+" "+ e.getString("mlsid"));
  
  
                  child2.add(childdata2);
  
  
  
  
           }
  
  
      }   
  
    }catch(JSONException e)        {
   Log.e("log_tag", "Error parsing data "+e.toString());
    }
  
  
  
  
  
         List&lt;List&lt;Map&lt;String, String&gt;&gt;&gt; childs = new ArrayList&lt;List&lt;Map&lt;String,   String&gt;&gt;&gt;();
          childs.add(child1);
          childs.add(child2);
  
  
  
  
      SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter(
              this, groups, R.layout.groups, new String[] { "group" },
              new int[] { R.id.group }, childs, R.layout.childs,
              new String[] { "0"}, new int[] { R.id.child });
          setListAdapter(adapter);
          }
  
       @Override
      public boolean setSelectedChild(int groupPosition, int childPosition,
               boolean shouldExpandGroup) {
          //do something
         Log.e("log_tag","setSelectedChild: "); 
           return super.setSelectedChild(groupPosition, childPosition,
                    shouldExpandGroup);
     }
  
      @Override
      public void setSelectedGroup(int groupPosition) {
      //do something
  
         Log.e("log_tag","setSelectedGroup: "); 
          super.setSelectedGroup(groupPosition);
  }
  
  
  **//Here I am Getting problem**
  
  @SuppressWarnings("unchecked")
  public boolean onChildClick(
             ExpandableListView parent, 
             View v, 
             int groupPosition,
             int childPosition,
             long id) {
  Log.d( "LOG_TAG", "onChildClick: "+"GROUP: "+groupPosition+"   CHILD Position:  "+ childPosition);
  
  HashMap&lt;String, String&gt; o =    (HashMap&lt;String, String&gt;)  parent.getItemAtPosition(childPosition+1);           
  
                String val = o.get("0");
            Log.d( "LOG_TAG", "selected value :  "+val  );
  
  
  
  
             return false;
  
         }
  
  
  
  
  
  
   }
  </code></pre>
  
  <p>LogCat Info when   public boolean onChildClick () called :</p>
  
  <pre><code>10-20 11:24:28.004: DEBUG/LOG_TAG(1652): onChildClick: GROUP: 0   CHILD Position:  0
  10-20 11:24:28.004: DEBUG/LOG_TAG(1652): selected value :  1 555
  10-20 11:24:42.454: DEBUG/LOG_TAG(1652): onChildClick: GROUP: 1   CHILD Position:  0
  10-20 11:24:42.454: DEBUG/LOG_TAG(1652): selected value :  1 555
  </code></pre>
  
  <p>Logcat shows that I am getting same value for group1(Active) and group2(Pending)</p>
  
  <p>I need specific value for each child view based on click.</p>