title: How do you set Android ViewPager to encompass only one View or Layout?
body: <p>I am struggling with the concepts needed to properly implement a view pager. By following some tutorials and referencing developer.android.com, I am able to get a view pager almost fully functional. The pager will flip through several text views that have been setup to say "My Message 0" through "My Message 9". The problem is that the view pager <em>also</em> flips the button on the bottom of the activity and the red block that is right above the button.</p>
  
  <p><img src="https://i.stack.imgur.com/VXNcW.jpg" alt="issues with view pager mid-flip"> </p>
  
  <p>I would like to have the view pager only cycle through the text. Would you please help me understand what I'm doing wrong?</p>
  
  <p>I have an activity that represents a dashboard: </p>
  
  <pre><code>public class DashBoard extends FragmentActivity
  {
    private static final int NUMBER_OF_PAGES = 10;
  
    private ViewPager mViewPager;
    private MyFragmentPagerAdapter mMyFragmentPagerAdapter;
  
    public void onCreate(Bundle icicle){
    super.onCreate(icicle);
    setContentView(R.layout.dashboard);
  
    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    mMyFragmentPagerAdapter = new    MyFragmentPagerAdapter(getSupportFragmentManager());
    mViewPager.setAdapter(mMyFragmentPagerAdapter);
  
    }
  
       private static class MyFragmentPagerAdapter extends FragmentPagerAdapter{
   public MyFragmentPagerAdapter(FragmentManager fm)
   {
       super(fm);
   }
  
   @Override
   public Fragment getItem(int index)
   {
       return PageFragment.newInstance("My Message " + index);
   }
  
   @Override
   public int getCount(){
       return NUMBER_OF_PAGES;
    }
    }
  </code></pre>
  
  <p>and a class for the page fragment:</p>
  
  <pre><code>public class PageFragment extends Fragment {
  
  public static PageFragment newInstance(String title){
  
    PageFragment pageFragment = new PageFragment();
    Bundle bundle = new Bundle();
    bundle.putString("title", title);
    pageFragment.setArguments(bundle);
    return pageFragment;
      }
  
      @Override
      public void onCreate(Bundle icicle){
    super.onCreate(icicle);
  
      }
  
      @Override
       public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle icicle){
    View view = inflater.inflate(R.layout.dashboard, container, false);
    TextView textView = (TextView) view.findViewById(R.id.textViewPage);
    textView.setText(getArguments().getString("title"));
    return view;
  
       }
  
      }
  </code></pre>
  
  <p>and finally, my xml for the dashboard:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/dashbaordLabel"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  &gt;
  
  &lt;android.support.v4.view.ViewPager
      android:id="@+id/viewpager"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_alignParentLeft="true"
      /&gt;
  &lt;TextView
      android:id="@+id/textViewPage"
      android:layout_width = "match_parent"
      android:layout_height= "wrap_content"
      /&gt;  
  
  &lt;Button
      android:id="@+id/newGoalButton"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="@string/stringNewGoal"
      android:layout_alignParentBottom="true"
      android:layout_alignParentLeft="true"
      android:onClick="createNewGoal"
      /&gt;
  
  &lt;RelativeLayout
      android:id="@+id/SpaceBottom"
      android:layout_width="match_parent"
      android:layout_height="75dp"
      android:layout_above="@id/newGoalButton"
      android:background="@color/red"
  &gt;
  
     &lt;/RelativeLayout&gt;
       &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>A note about my xml, I tried wrapping the text view in some view pager tags eg:</p>
  
  <pre><code>&lt;android.support.v4.view.ViewPager
      android:id="@+id/viewpager"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_alignParentLeft="true"
      &gt;
  &lt;TextView
      android:id="@+id/textViewPage"
      android:layout_width = "match_parent"
      android:layout_height= "wrap_content"
      /&gt;  
  &lt;/android.support.v4.view.ViewPager&gt;
  </code></pre>
  
  <p>But all that did was make the text view disappear from the screen, while the button and red block still cycled as in the original issue.</p>