title: Mixing listview and pageview in Android to make a swipe-able settings menu
body: <p>Hey so I am trying to create a settings menu that is swipped to from the main screen. I used Pager Adapter to create a three page view that a user can swipe to from a center screen.</p>
  
  <p>I.e:</p>
  
  <pre><code>        POST SCREEN   ------SWIPE------- HOME ------SWIPE---------- SETTINGS SCREEN
  </code></pre>
  
  <p>I now want to populate the settings screen with a nice list view to be able to create a menu for the user to pick and choose from. The problem I am having is integrating that with the pageAdapter I have implemented. The issue <em>I think</em> is that I to get the page swipping to work I only have one activity with many view (being 3 in this case). But for the listView adapter I need a separate activity.</p>
  
  <p>I may be mistaken completely in this case but some clarification would be awesome.</p>
  
  <p>Here is what I have so far: <strong>MainActivity.java</strong></p>
  
  <pre><code>import android.annotation.SuppressLint;
  import android.app.Activity;
  import android.content.Context;
  import android.os.Bundle;
  import android.os.Parcelable;
  import android.support.v4.view.PagerAdapter;
  import android.support.v4.view.ViewPager;
  import android.view.LayoutInflater;
  import android.view.View;
  
  
  /** Called when the activity is first created. */
  @SuppressLint("NewApi")
  public class MainActivity extends Activity {
  
   /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      // PAGE ADAPTER CONTENT
      MyPagerAdapter adapter = new MyPagerAdapter();
      ViewPager myPager = (ViewPager) findViewById(R.id.threepagemainview);
      myPager.setAdapter(adapter);
      myPager.setCurrentItem(1);
  
  }
  
  
  /**
   * 
   * @author Andy
   * 
   * This method is a data adapter to determine and load the appropriate content 
   * for each page the user swipes to
   * 
   * We have the main view set to case 1 -&gt; main menu
   * and left view to post, right view to settings
   * 
   */
  private class MyPagerAdapter extends PagerAdapter {
  
          /**
           * This will get the count for the amount of pages to return
           */
          public int getCount() {
                  return 3;
          }
  
          /**
           * This method will inflate the appropriate layout resource file
           * depending on the users swipe position.
           */
          public Object instantiateItem(View collection, int position) {
  
                  LayoutInflater inflater = (LayoutInflater) collection.getContext()
                                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
                  int resId = 0;
                  switch (position) {
                  case 0:
                          resId = R.layout.view_post;
                          break;
                  case 1:
                          resId = R.layout.view_middle;
                          break;
                  case 2:
                          resId = R.layout.view_settings;
                          break;
                  }
                  View view = inflater.inflate(resId, null);
  
                  ((ViewPager) collection).addView(view, 0);
  
                  return view;
          }
  
          @Override
          public void destroyItem(View arg0, int arg1, Object arg2) {
                  ((ViewPager) arg0).removeView((View) arg2);
          }
  
          @Override
          public void finishUpdate(View arg0) {
          }
  
          @Override
          public boolean isViewFromObject(View arg0, Object arg1) {
                  return arg0 == ((View) arg1);
          }
  
          @Override
          public void restoreState(Parcelable arg0, ClassLoader arg1) {
          }
  
          @Override
          public Parcelable saveState() {
                  return null;
          }
  
          @Override
          public void startUpdate(View arg0) {
          }
  }
  }
  </code></pre>
  
  <p>And for the XML files I simple have a plain file with a view text. This is completely bare bones at the moment.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks</p>
  
  <p>A</p>