title: Android Expandable List - OnClickListener
body: <p>I'm having trouble with setting an OnClickListener to list items in my ExpandableListActivity. The code structure matches the following example:</p>
  
  <pre><code>    ExpandableListAdapter mAdapter;
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      // Assign the adapter
      mAdapter = new MyExpandableListAdapter();
      setListAdapter(mAdapter);
  }
  
  public class MyExpandableListAdapter extends BaseExpandableListAdapter {
      private String[] groups = { "foo", "bar"};
      private String[][] children = {
                  {"fooA", "barA"},
          {"fooB", "barB"}
              };
  
      public Object getChild(int groupPosition, int childPosition) {
          return children[groupPosition][childPosition];
      }
  
      public long getChildId(int groupPosition, int childPosition) {
          return childPosition;
      }
  
      public int getChildrenCount(int groupPosition) {
          return children[groupPosition].length;
      }
  
      public TextView getGenericView() {
          // Layout parameters for the ExpandableListView
          AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
                  ViewGroup.LayoutParams.MATCH_PARENT, 64);
  
          TextView textView = new TextView(Calculations.this);
          textView.setLayoutParams(lp);
          // Center the text vertically
          textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
          // Set the text starting position
          textView.setPadding(64, 0, 0, 0);
          return textView;
      }
  
          public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
              View convertView, ViewGroup parent) {
          TextView textView = getGenericView();
          textView.setText(getChild(groupPosition, childPosition).toString());
          textView.setPadding(98, 0, 0, 0);
          return textView;
      }
  
      public Object getGroup(int groupPosition) {
          return groups[groupPosition];
      }
  
      public int getGroupCount() {
          return groups.length;
      }
  
      public long getGroupId(int groupPosition) {
          return groupPosition;
      }
  
      public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
              ViewGroup parent) {
          TextView textView = getGenericView();
          textView.setText(getGroup(groupPosition).toString());
          return textView;
      }
  
      public boolean isChildSelectable(int groupPosition, int childPosition) {
          return true;
      }
  
      public boolean hasStableIds() {
          return true;
      }
  }
  </code></pre>
  
  <p>Once I'm able to set the listener, I'll most likely do something like this:</p>
  
  <pre><code>// Listener
  {
      switch(groupPosition) {
      case 0:
          switch(childPosition) {
          case 0:
              selected = 00;
              return true;
          }
      }
  }// Close listener
  </code></pre>
  
  <p>Please tell me if I'm not being clear enough.</p>