title: Android :- Custom ExpandableListView : cannot expand group item to display child item in CustomListView
body: <p>I'm trying to implement a custom ExpandableListView inside a SherlockFragment. I followed this <a href="http://shenhengbin.wordpress.com/2012/03/25/android-practice-custom-expandablelistview-sample-2/" rel="nofollow">sample</a> to extend BaseExpandableListAdapter and create my custom adapter.</p>
  
  <p><strong>Here is my problem, when my expandable list is displayed on the screen I can see all the group item, but when I click on one of them, the child item which are supposed to be displayed below it don't show up</strong>.</p>
  
  <ol>
  <li><p>I tried to debug it, the onGroupExpandListener I put in the adapter is never called, and actually I put breakpoints in the different methods of my adapter, there are not called ever when I click on one of the group item.</p></li>
  <li><p>I tried to modify my xml files which define the group item and the child item, to make them clickable or focus-able, nothing changed. I also tried to remove the editText, Button, and CheckBox I put in there, thinking it was may be creating a conflict ...</p></li>
  <li><p>I thought the problem was may be due to some incompatibility issues using ExpandableListView with SherlockFragment, but according to the developer's <a href="https://groups.google.com/forum/?fromgroups=#!topic/actionbarsherlock/VxD_FS9wzas" rel="nofollow">forum</a> its not.</p></li>
  </ol>
  
  <p>So I really don't know where to look now, it's may be simply a rookie mistake I did in my adapter...
  Any help would be great,</p>
  
  <p>Thanks in advance!</p>
  
  <hr>
  
  <p>here is my code:</p>
  
  <pre><code>public class BuildingExpandalbeListAdapter extends BaseExpandableListAdapter {
  
  private Context mContext;
  private ExpandableListView mExpandableListView;
  private SideEntity[] mSidesCollection;
  private int[] groupStatus;
  
  public BuildingExpandalbeListAdapter(Context pContext,
          ExpandableListView pExpandableListView,
          SideEntity[] pSidesCollection) {
      mContext = pContext;
      mSidesCollection = pSidesCollection;
      mExpandableListView = pExpandableListView;
      groupStatus = new int[mSidesCollection.length];
      mExpandableListView.setClickable(true);     
      setListEvent();
  }
  
  private void setListEvent() {
  
      mExpandableListView
              .setOnGroupExpandListener(new OnGroupExpandListener() {
  
                  @Override
                  public void onGroupExpand(int arg0) {
                      // TODO Auto-generated method stub
                      groupStatus[arg0] = 1;
                  }
              });
  
      mExpandableListView
              .setOnGroupCollapseListener(new OnGroupCollapseListener() {
  
                  @Override
                  public void onGroupCollapse(int arg0) {
                      // TODO Auto-generated method stub
                      groupStatus[arg0] = 0;
                  }
              });
  }
  
  @Override
  public Object getChild(int groupPosition, int childPosition) {
      return mSidesCollection[groupPosition].getSegmentEntity(childPosition)
              .getName();
  }
  
  @Override
  public long getChildId(int groupPosition, int childPosition) {
      return mSidesCollection[groupPosition].getSegmentEntity(childPosition)
              .getId();
  }
  
  @Override
  public View getChildView(int groupPosition, int childPosition,
          boolean isLastChild, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
      ChildHolder childHolder;
      if (convertView == null) {
          convertView = LayoutInflater.from(mContext).inflate(
                  R.layout.building_list_item, null);
  
          childHolder = new ChildHolder();
  
          childHolder.editText1 = (EditText) convertView
                  .findViewById(R.id.editText1);
          childHolder.checkBox1 = (CheckBox) convertView
                  .findViewById(R.id.checkBox1);
          convertView.setTag(childHolder);
      } else {
          childHolder = (ChildHolder) convertView.getTag();
      }
  
      childHolder.editText1.setText(mSidesCollection[groupPosition]
              .getSegmentEntity(childPosition).getName());
      childHolder.checkBox1.setChecked(mSidesCollection[groupPosition]
              .getSegmentEntity(childPosition).hasDoor());
      return convertView;
  }
  
  @Override
  public int getChildrenCount(int groupPosition) {
      // TODO Auto-generated method stub
      return mSidesCollection[groupPosition].getSegmentsCollection().size();
  }
  
  @Override
  public Object getGroup(int groupPosition) {
      // TODO Auto-generated method stub
      return mSidesCollection[groupPosition];
  }
  
  @Override
  public int getGroupCount() {
      // TODO Auto-generated method stub
      return mSidesCollection.length;
  }
  
  @Override
  public long getGroupId(int groupPosition) {
      // TODO Auto-generated method stub
      return groupPosition;
  }
  
  @Override
  public View getGroupView(int groupPosition, boolean isExpanded,
          View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
      GroupHolder groupHolder;
      if (convertView == null) {
          convertView = LayoutInflater.from(mContext).inflate(
                  R.layout.building_list_group, null);
          groupHolder = new GroupHolder();
          groupHolder.editText1 = (EditText) convertView
                  .findViewById(R.id.editText1);
          groupHolder.editText2 = (EditText) convertView
                  .findViewById(R.id.editText2);
          convertView.setTag(groupHolder);
      } else {
          groupHolder = (GroupHolder) convertView.getTag();
      }
  
      groupHolder.editText1
              .setText(mSidesCollection[groupPosition].getName());
      groupHolder.editText2.setText(Integer
              .toString(mSidesCollection[groupPosition]
                      .getSegmentsCollection().size()));
  
      return convertView;
  }
  
  class GroupHolder {
      EditText editText1;
      EditText editText2;
  }
  
  class ChildHolder {
      EditText editText1;
      CheckBox checkBox1;
  }
  
  @Override
  public boolean hasStableIds() {
      // TODO Auto-generated method stub
      return true;
  }
  
  @Override
  public boolean isChildSelectable(int groupPosition, int childPosition) {
      // TODO Auto-generated method stub
      return true;
  }
  
  }
  </code></pre>
  
  <p>Here is my SherlockFragment using this adapter :</p>
  
  <pre><code>public class BuildingFragment extends SherlockFragment {
  
  private ViewGroup myViewGroup;
  private View v;
  private SideEntity[] mSideCollection;
  
  private BuildingsDbAdapter buildingDataBase;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      if (container == null) {
          return null;
      }
      myViewGroup = container;
      myViewGroup.removeAllViews();
      v = inflater.inflate(R.layout.building_data_layout, container, false);
      buildingDataBase = new BuildingsDbAdapter(getSherlockActivity());
      return v;
  }
  
  @Override
  public void onResume() {
      super.onResume();
      buildingDataBase.open();
      mSideCollection = BuildingsDbAdapter
              .fetchSideMatchingBuildingId(CustomTabFragmentActivity.mBuildingId);
      for (int i = 0; i &lt; mSideCollection.length; i++) {
          BuildingsDbAdapter.fetchSegmentMatchingSideId(
                  mSideCollection[i].getId(), mSideCollection[i]);
      }
      ExpandableListView mExpandableListView = (ExpandableListView) v
              .findViewById(R.id.expandableListView1);
      BuildingExpandalbeListAdapter mAdapter = new BuildingExpandalbeListAdapter(
              v.getContext().getApplicationContext(), mExpandableListView,
              mSideCollection);
      mExpandableListView.setAdapter(mAdapter);
      buildingDataBase.close();
  }
  }
  </code></pre>
  
  <p>and here is my xml files :</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" &gt;
  
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/linearLayout1"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal" &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="0dip"
          android:layout_height="wrap_content"
          android:layout_gravity="left|center_vertical"
          android:layout_marginLeft="10dip"
          android:layout_weight="3"
          android:singleLine="true"
          android:text="Building name: "
          android:textColor="@android:color/black"
          android:textSize="13dip" /&gt;
  
      &lt;TextView
          android:id="@+id/textView2"
          android:layout_width="0dip"
          android:layout_height="wrap_content"
          android:layout_gravity="left|center_vertical"
          android:layout_marginLeft="10dip"
          android:layout_weight="4"
          android:singleLine="true"
          android:text="Columbia Tower"
          android:textColor="@android:color/black"
          android:textSize="15dip"
          android:textStyle="italic" /&gt;
  
     &lt;!--  &lt;Button
          android:id="@+id/button1"
          android:layout_width="0dip"
          android:layout_height="30dp"
          android:layout_gravity="right|center_vertical"
          android:layout_marginRight="10dip"
          android:layout_weight="1"
          android:background="@color/honeycombish_blue"
          android:drawableTop="@drawable/edit_query"
          android:gravity="center_vertical|center_horizontal" /&gt; --&gt;
  &lt;/LinearLayout&gt;
  
  &lt;ExpandableListView
      android:id="@+id/expandableListView1"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:scrollbars="none"
      android:divider="@android:color/black"
      android:clipChildren="false"
      android:focusable="true" &gt;
  &lt;/ExpandableListView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>the group_item :</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/RelativeLayout"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:clickable="true"
  android:gravity="center_vertical"
  android:orientation="vertical" &gt;
  
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/linearLayout1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/RelativeLayout"
      android:layout_marginTop="6dip"
      android:layout_toLeftOf="@+id/button1"
      android:orientation="horizontal" &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="0dip"
          android:layout_height="wrap_content"
          android:layout_gravity="left|center_vertical"
          android:layout_marginLeft="5dip"
          android:layout_weight="2"
          android:singleLine="true"
          android:text="Side: "
          android:textColor="@android:color/black"
          android:textSize="13dip" /&gt;
  
      &lt;EditText
          android:id="@+id/editText1"
          android:layout_width="0dip"
          android:layout_height="wrap_content"
          android:layout_gravity="left|center_vertical"
          android:layout_marginLeft="5dip"
          android:layout_weight="2"
          android:singleLine="true"
          android:textColor="@android:color/black"
          android:textSize="15dip"
          android:textStyle="italic" /&gt;
  
      &lt;TextView
          android:id="@+id/textView3"
          android:layout_width="0dip"
          android:layout_height="wrap_content"
          android:layout_gravity="left|center_vertical"
          android:layout_marginLeft="5dip"
          android:layout_weight="5"
          android:singleLine="true"
          android:text="Number of Segment:"
          android:textColor="@android:color/black"
          android:textSize="13dip" /&gt;
  
      &lt;EditText
          android:id="@+id/editText2"
          android:layout_width="0dip"
          android:layout_height="wrap_content"
          android:layout_gravity="left|center_vertical"
          android:layout_marginLeft="5dip"
          android:layout_weight="2"
          android:ems="10"
          android:inputType="number"
          android:text="0"
          android:textSize="13dip" /&gt;
  &lt;/LinearLayout&gt;
  
  &lt;Button
      android:id="@+id/button1"
      android:layout_width="30dip"
      android:layout_height="30dip"
      android:layout_alignBottom="@+id/linearLayout1"
      android:layout_alignParentRight="true"
      android:layout_marginLeft="2dip"
      android:background="@android:color/transparent"
      android:drawableBottom="@drawable/ic_edit_shape"
      android:gravity="bottom|center_horizontal" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>the list_item :</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/RelativeLayout"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:clickable="true"
  android:orientation="vertical" &gt;
  
  &lt;Button
      android:id="@+id/button1"
      android:layout_width="30dip"
      android:layout_height="30dip"
      android:layout_alignBottom="@+id/linearLayout1"
      android:layout_alignParentLeft="true"
      android:layout_marginLeft="2dip"
      android:background="@android:color/transparent"
      android:drawableBottom="@drawable/ic_edit_shape"
      android:gravity="bottom|center_horizontal" /&gt;
  
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/linearLayout1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/RelativeLayout"
      android:layout_marginTop="6dip"
      android:layout_toRightOf="@+id/button1"
      android:orientation="horizontal" &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="0dip"
          android:layout_height="wrap_content"
          android:layout_gravity="left|center_vertical"
          android:layout_marginLeft="5dip"
          android:layout_weight="2"
          android:singleLine="true"
          android:text="Name: "
          android:textColor="@android:color/black"
          android:textSize="13dip" /&gt;
  
      &lt;EditText
          android:id="@+id/editText1"
          android:layout_width="0dip"
          android:layout_height="wrap_content"
          android:layout_gravity="left|center_vertical"
          android:layout_marginLeft="5dip"
          android:layout_weight="2"
          android:singleLine="true"
          android:text="Shop1"
          android:textColor="@android:color/black"
          android:textSize="15dip"
          android:textStyle="italic" /&gt;
  
      &lt;CheckBox
          android:id="@+id/checkBox1"
          android:layout_width="0dip"
          android:layout_height="30dip"
          android:layout_weight="1"
          android:hint="Door" /&gt;
  &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>