title: Nested ExpandableListView Only Works Every Other Child
body: <p>I have a system of nested ExpandableListViews that continue on for a few generations (a tree-type layout) for comments. Each top-level comment can have comments with children on those comments. To do so, I have a main ExpandableListView to store all the top level comments, and each "comment" XML contains an ExpandableListView for any child comments. The adapter for my ExpandableListView is as follows</p>
  
  <pre><code>public class ExpandableCommentAdapter extends BaseExpandableListAdapter {
  
      private static final class ViewHolder {
          TextView textLabel;
      }
  
      private final List&lt;CommentNode&gt; itemList;
      private final LayoutInflater inflater;
      private Context main;
  
      public ExpandableCommentAdapter(Context context, List&lt;CommentNode&gt; itemList) {
          this.inflater = LayoutInflater.from(context);
          this.itemList = itemList;
          main = context;
  
  
      }
  
      @Override
      public CommentNode getChild(int groupPosition, int childPosition) {
  
          CommentNode n = itemList.get(groupPosition);
          ArrayList&lt;CommentNode&gt; comments = new ArrayList&lt;CommentNode&gt;();
          for (CommentNode node : n.walkTree(TraversalMethod.BREADTH_FIRST)) {
              if (node.getParent().getComment().getId() == n.getComment().getId()) {
                  comments.add(node);
              }
  
          }
          Log.v("RedditSlide", "COMMENT CHILD SIZE:" + comments.size());
          return comments.get(childPosition);
      }
  
      @Override
      public long getChildId(int groupPosition, int childPosition) {
          return childPosition;
      }
  
      @Override
      public int getChildrenCount(int groupPosition) {
          CommentNode n = itemList.get(groupPosition);
          ArrayList&lt;CommentNode&gt; comments = new ArrayList&lt;CommentNode&gt;();
          CommentNode comment = n;
          for (CommentNode node : comment.walkTree(TraversalMethod.BREADTH_FIRST)) {
              if (node.getParent().getComment().getId() == comment.getComment().getId()) {
                  comments.add(node);
              }
  
          }
          return comments.size();
      }
  
      @Override
      public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
                               final ViewGroup parent) {
  
          final CommentNode user = getChild(groupPosition, childPosition);
          if (convertView == null) {
              convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.comment, parent, false);
          }
          TextView author = (TextView) convertView.findViewById(R.id.author);
          TextView comm = (TextView) convertView.findViewById(R.id.commentLine);
          TextView upvote = (TextView) convertView.findViewById(R.id.upvotePost);
  
          author.setText(user.getComment().getAuthor());
          comm.setText(user.getComment().getBody());
          upvote.setText(user.getComment().getScore() + "");
  
  
          ArrayList&lt;CommentNode&gt; comments = new ArrayList&lt;CommentNode&gt;();
          CommentNode comment = user;
          for (CommentNode node : comment.walkTree(TraversalMethod.BREADTH_FIRST)) {
              if (node.getParent().getComment().getId() == comment.getComment().getId()) {
                  comments.add(node);
              }
  
          }
  
          ExpandableCommentAdapter adapter = new ExpandableCommentAdapter(convertView.getContext(), comments);
          ExpandableListView listView = (ExpandableListView) convertView.findViewById(R.id.commentsListUnder);
          listView.setAdapter(adapter);
  
  
          return convertView;
      }
  
      @Override
      public CommentNode getGroup(int groupPosition) {
          return itemList.get(groupPosition);
      }
  
      @Override
      public int getGroupCount() {
          return itemList.size();
      }
  
      @Override
      public long getGroupId(final int groupPosition) {
          return groupPosition;
      }
  
      @Override
      public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
  
          final CommentNode user = itemList.get(groupPosition);
          if (convertView == null) {
              convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.comment, parent, false);
          }
          TextView author = (TextView) convertView.findViewById(R.id.author);
          TextView comm = (TextView) convertView.findViewById(R.id.commentLine);
          TextView upvote = (TextView) convertView.findViewById(R.id.upvotePost);
  
          author.setText(user.getComment().getAuthor());
          comm.setText(user.getComment().getBody());
          upvote.setText(user.getComment().getScore() + "");
  
          return convertView;
      }
  
      @Override
      public boolean hasStableIds() {
          return true;
      }
  
      @Override
      public boolean isChildSelectable(int groupPosition, int childPosition) {
          return true;
      }
  
  
  }
  </code></pre>
  
  <p>My Comment XML is as follows</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginBottom="-20dp"
      android:layout_marginRight="-20dp"
  
      android:background="#ff2b2b2b"
      android:orientation="vertical"
      android:padding="20dp"
      android:paddingBottom="0dp"
      android:paddingEnd="0dp"
      android:scrollbars="none"&gt;
  
      &lt;TextView
          android:id="@+id/author"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="ccrama"
          android:textSize="12dp" /&gt;
  
      &lt;TextView
          android:id="@+id/commentLine"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="COMMENT"
          android:textSize="14dp" /&gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginLeft="-10dp"
          android:orientation="horizontal"&gt;
  
          &lt;ImageView
              android:id="@+id/upvote"
              android:layout_width="20dp"
              android:layout_height="20dp"
  
              android:layout_gravity="center_vertical"
              android:layout_margin="10dp"
              android:background="@drawable/roundbutton"
              android:onClick="upvote"
              android:padding="5dp"
  
              android:scaleType="fitCenter"
              android:src="@drawable/iconupvote"
  
              /&gt;
  
          &lt;ImageView
              android:id="@+id/downvote"
              android:layout_width="20dp"
  
              android:layout_height="20dp"
              android:layout_gravity="center_vertical"
              android:layout_marginLeft="-7dp"
              android:background="@drawable/roundbutton"
  
              android:onClick="downvote"
  
              android:padding="5dp"
              android:scaleType="fitCenter"
              android:src="@drawable/icondownvote"
  
              /&gt;
  
          &lt;TextView
              android:id="@+id/upvotePost"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="center_vertical"
  
              android:layout_marginLeft="7dp"
              android:text="30"
              android:textSize="14dp" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;ExpandableListView xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/commentsListUnder"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginBottom="-20dp"
          android:layout_marginLeft="-5dp"
          android:layout_marginRight="-20dp"
          android:background="#ff2b2b2b"
          android:orientation="vertical" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>The issue I'm having is the "expandableness" of the child comments seems to skip a generation. Level 1, Level 3, etc all have expansion and their children are visible, but Level 2 can't expand, and only one child is visible. Further children (4, 5, 6...) aren't visible, and Level 3 <em>has</em> an expanding icon but when tapped shows no children. </p>
  
  <p>What am I doing wrong with my layout/system?
  Thanks!</p>