title: Add ExpandableListView in Tabs
body: <p>This is my problem:</p>
  
  <p>I have created a four-tabs application (named: Day 1, Day 2, Day 3 and Day 4) and each tab has a layout. The problem is that this layout can contain only Text Views and strings, but I need to insert a more complex ExpandableListView with its own java class in each Tab, the result I would like is something like the "contacts" application.</p>
  
  <p>My main activity is:</p>
  
  <pre><code>package tabs;
  
  import android.app.ActionBar;
  import android.app.FragmentTransaction;
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentActivity;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentPagerAdapter;
  import android.support.v4.view.ViewPager;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  public class MainActivity extends FragmentActivity implements
      ActionBar.TabListener {
  
     CollectionPagerAdapter mCollectionPagerAdapter;
  
     ViewPager mViewPager;
  
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
      mCollectionPagerAdapter = new CollectionPagerAdapter(
          getSupportFragmentManager());
  
      // Set up action bar.
      final ActionBar actionBar = getActionBar();
  
  
      // Specify that we will be displaying tabs in the action bar.
      actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  
      // Set up the ViewPager, attaching the adapter and setting up a listener
      // for when the
      // user swipes between sections.
      mViewPager = (ViewPager) findViewById(R.id.pager);
      mViewPager.setAdapter(mCollectionPagerAdapter);
      mViewPager
          .setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
              @Override
              public void onPageSelected(int position) {
  
              actionBar.setSelectedNavigationItem(position);
              }
          });
  
      // For each of the sections in the app, add a tab to the action bar.
      for (int i = 0; i &lt; mCollectionPagerAdapter.getCount(); i++) {
  
          actionBar.addTab(actionBar.newTab()
              .setText(mCollectionPagerAdapter.getPageTitle(i))
              .setTabListener(this));
      }
      }
  
      public void onTabUnselected(ActionBar.Tab tab,
          FragmentTransaction fragmentTransaction) {
      }
  
      public void onTabSelected(ActionBar.Tab tab,
          FragmentTransaction fragmentTransaction) {
      // When the given tab is selected, switch to the corresponding page in
      // the ViewPager.
      mViewPager.setCurrentItem(tab.getPosition());
      }
  
      public void onTabReselected(ActionBar.Tab tab,
          FragmentTransaction fragmentTransaction) {
      }
  
  
      public class CollectionPagerAdapter extends FragmentPagerAdapter {
  
      final int NUM_ITEMS = 4; // number of tabs
  
      public CollectionPagerAdapter(FragmentManager fm) {
          super(fm);
      }
  
      @Override
      public Fragment getItem(int i) {
          Fragment fragment = new TabFragment();
          Bundle args = new Bundle();
          args.putInt(TabFragment.ARG_OBJECT, i);
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public int getCount() {
          return NUM_ITEMS;
      }
  
      @Override
      public CharSequence getPageTitle(int position) {
          String tabLabel = null;
          switch (position) {
          case 0:
          tabLabel = getString(R.string.title_section1);
          break;
          case 1:
          tabLabel = getString(R.string.title_section2);
          break;
          case 2:
          tabLabel = getString(R.string.title_section3);
          break;
          case 3:
          tabLabel = getString(R.string.title_section4);
          break;
          }
  
          return tabLabel;
      }
      }
  
  
      public static class TabFragment extends Fragment {
  
      public static final String ARG_OBJECT = "object";
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
          Bundle args = getArguments();
          int position = args.getInt(ARG_OBJECT);
  
          int tabLayout = 0;
          switch (position) {
          case 0:
          tabLayout = R.layout.tab1;
          break;
          case 1:
          tabLayout = R.layout.tab2;
          break;
          case 2:
          tabLayout = R.layout.tab3;
          break;
          case 3:
          tabLayout = R.layout.tab4;
          break;
          }
  
          View rootView = inflater.inflate(tabLayout, container, false);
  
          return rootView;
      }
      }}
  </code></pre>
  
  <p>The main xml layout is</p>
  
  <pre><code>&lt;android.support.v4.view.ViewPager 
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/pager"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
  &lt;/android.support.v4.view.ViewPager&gt;
  </code></pre>
  
  <p>The Tabs layout is (they all are the same but with different texts, this one is just "hello")</p>
  
  
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/tab2"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" 
      android:gravity="center"&gt;
  
      &lt;TextView
          android:id="@+id/textView2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:text="one" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>