title: How to implement an ExpandableList in a ViewPager in Android?
body: <p><strong>How to implement an ExpandableList in a ViewPager in Android ?</strong></p>
  <p>This is a simple 1 file ExpandableList provided by google</p>
  <pre><code>/*
   * Copyright (C) 2007 The Android Open Source Project
   *
   * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  package com.example.android.apis.view;
  
  import android.app.ExpandableListActivity;
  import android.os.Bundle;
  import android.widget.ExpandableListAdapter;
  import android.widget.SimpleExpandableListAdapter;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  
  /**
   * Demonstrates expandable lists backed by a Simple Map-based adapter
   */
  public class ExpandableList3 extends ExpandableListActivity {
      private static final String NAME = &quot;NAME&quot;;
      private static final String IS_EVEN = &quot;IS_EVEN&quot;;
  
      private ExpandableListAdapter mAdapter;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          List&lt;Map&lt;String, String&gt;&gt; groupData = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
          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 (int i = 0; i &lt; 20; i++) {
              Map&lt;String, String&gt; curGroupMap = new HashMap&lt;String, String&gt;();
              groupData.add(curGroupMap);
              curGroupMap.put(NAME, &quot;Group &quot; + i);
              curGroupMap.put(IS_EVEN, (i % 2 == 0) ? &quot;This group is even&quot; : &quot;This group is odd&quot;);
  
              List&lt;Map&lt;String, String&gt;&gt; children = new ArrayList&lt;Map&lt;String, String&gt;&gt;();
              for (int j = 0; j &lt; 15; j++) {
                  Map&lt;String, String&gt; curChildMap = new HashMap&lt;String, String&gt;();
                  children.add(curChildMap);
                  curChildMap.put(NAME, &quot;Child &quot; + j);
                  curChildMap.put(IS_EVEN, (j % 2 == 0) ? &quot;This child is even&quot; : &quot;This child is odd&quot;);
              }
              childData.add(children);
          }
  
          // Set up our adapter
          mAdapter = new SimpleExpandableListAdapter(
                  this,
                  groupData,
                  android.R.layout.simple_expandable_list_item_1,
                  new String[] { NAME, IS_EVEN },
                  new int[] { android.R.id.text1, android.R.id.text2 },
                  childData,
                  android.R.layout.simple_expandable_list_item_2,
                  new String[] { NAME, IS_EVEN },
                  new int[] { android.R.id.text1, android.R.id.text2 }
                  );
          setListAdapter(mAdapter);
      }
  
  }
  </code></pre>
  <p>And <a href="http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html" rel="nofollow noreferrer">here</a> is where i learned to use the viewpager</p>
  <p>now i want to use those together, but i don't know how :(</p>
  <p>I've tried to put the code in InstantiateIitem within the viewpager, but that didn't work, i tried making the viewpager an activty that extenda ExpandableListActivity, but it gave me a bunch of runtime exceptions kept trying o fix one at a time, but reached nowwhere at the end, i kept trying stuff that didn't make sense to me anymore so i stopped and asked here</p>