title: need help to understand onChildClick android
body: <p>Hello i have succeeded to make an expandable list view in my app from an example and much struggle, but i don't really understand how i succeeded to get the right index the user clicked, i mean, i don't really know what's in childData and how groupData and childData are related to each other. I need some help understanding this guys, i had never seen generics in this way. So here are my questions: </p>
  
  <p>1- How childData and groupData are related to each other, is groupData into childData Map?
  2- How can <code>String selectedWord = childData.get(groupPosition).get(childPosition).get(NAME);</code>
     get the right word and header(or group) in the listView?</p>
  
  <p>Here's the code:</p>
  
  <pre><code>@Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.expandable_list_layout);
  
          DBManager db = new DBManager(getApplicationContext());
  
          List&lt;String&gt; header = db.selectAllCategories();
          List&lt;Map&lt;String, String&gt;&gt; groupData = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
          final List&lt;List&lt;Map&lt;String, String&gt;&gt;&gt; childData = new ArrayList&lt;List&lt;Map&lt;String, String&gt;&gt;&gt;();
  
          for (String category : header) {
              Map&lt;String, String&gt; curGroupMap = new HashMap&lt;String, String&gt;();
              groupData.add(curGroupMap);
              curGroupMap.put(NAME, category);
              List&lt;String&gt; categoryWords = db.selectWordsFromCategory(category);
  
              List&lt;Map&lt;String, String&gt;&gt; children = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
              for (String word : categoryWords) {
                  Map&lt;String, String&gt; curChildMap = new HashMap&lt;String, String&gt;();
                  children.add(curChildMap);
  
                  curChildMap.put(NAME, word);
              }
              childData.add(children);
          }
  
          //create SimpleExpandableListAdapter object...
  
          lv.setOnChildClickListener(new OnChildClickListener() {
  
              public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
  
  //How does the below code works? 
  //How can i get the group value from the childData map
  //i thought childData had only childs in it?
                  String selectedWord = childData.get(groupPosition).get(childPosition).get(NAME);
  
                  Log.i("You clicked here:", selectedWord)
                  return false;
              }
          });
  </code></pre>
  
  <p>Thanks for your time.</p>