title: Auto-flipping images in ViewFlipper inside a fragment
body: <p>I am trying to automatically change images inside a fragment using ViewFlipper. My activity code is :</p>
  
  <pre><code>package com.example.scientia;
  
  import android.app.Activity;
  import android.app.ActionBar;
  import android.app.Fragment;
  import android.app.FragmentManager;
  import android.app.FragmentTransaction;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ViewGroup;
  import android.support.v4.widget.DrawerLayout;
  import android.widget.Toast;
  import android.widget.ViewFlipper;
  
  public class HomeActivity extends Activity implements NavigationDrawerFragment.NavigationDrawerCallbacks {
  
      private NavigationDrawerFragment mNavigationDrawerFragment; //manages behaviors of navigation drawer
  
      private CharSequence mTitle; //stores title of last screen
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_home);
  
          mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.navigation_drawer);
          mTitle = getTitle();
  
          // Set up the drawer.
          mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));
      }
  
      @Override
      public void onNavigationDrawerItemSelected(int position) {
          // update the main content by replacing fragments
          FragmentManager fragmentManager = getFragmentManager();
          FragmentTransaction ft = fragmentManager.beginTransaction();
          fragmentManager.beginTransaction().replace(R.id.fragment1, PlaceholderFragment.newInstance(position + 1))
                  .commit();
          if(position == 0)
          {
              Fragment f1 = new HomeFragment();
              ft.replace(R.id.fragment1, f1);
              ft.commit();
          }
          if(position == 1)
          {
              Fragment f1 = new IqQuiz();
              ft.replace(R.id.fragment1, f1);
              ft.commit();
          }
          if(position == 2)
          {
              Fragment f1 = new LogicalQuiz();
              ft.replace(R.id.fragment1, f1);
              ft.commit();
          }
          if(position == 3)
          {
              Fragment f1 = new AptitudeQuiz();
              ft.replace(R.id.fragment1, f1);
              ft.commit();
          }
          if(position == 4)
          {
              Fragment f1 = new VerbalQuiz();
              ft.replace(R.id.fragment1, f1);
              ft.commit();
          }
      }
  
      public void onSectionAttached(int number) {
          switch (number) {
          case 1:
              mTitle = getString(R.string.title_section1);
              break;
          case 2:
              mTitle = getString(R.string.title_section2);
              break;
          case 3:
              mTitle = getString(R.string.title_section3);
              break;
          case 4:
              mTitle = getString(R.string.title_section4);
              break;
          case 5:
              mTitle = getString(R.string.title_section5);
              break;
          }
      }
  
      public void restoreActionBar() {
          ActionBar actionBar = getActionBar();
          actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
          actionBar.setDisplayShowTitleEnabled(true);
          actionBar.setTitle(mTitle);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          if (!mNavigationDrawerFragment.isDrawerOpen()) {
              getMenuInflater().inflate(R.menu.home, menu);
              restoreActionBar();
              return true;
          }
          return super.onCreateOptionsMenu(menu);
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) { //handles action bar item clicks
          int id = item.getItemId();
          if (id == R.id.action_settings) {
              return true;
          }
          return super.onOptionsItemSelected(item);
      }
  
      public static class PlaceholderFragment extends Fragment { //placeholder containes a simple view
  
          private static final String ARG_SECTION_NUMBER = "section_number";
  
          public static PlaceholderFragment newInstance(int sectionNumber) {
              PlaceholderFragment fragment = new PlaceholderFragment(); //returns new fragment for the section number
              Bundle args = new Bundle();
              args.putInt(ARG_SECTION_NUMBER, sectionNumber);
              fragment.setArguments(args);
              return fragment;
          }
  
          public PlaceholderFragment() {
          }
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
              View rootView = inflater.inflate(R.layout.fragment_home, container, false);
              ViewFlipper viewflipper = (ViewFlipper) rootView.findViewById(R.id.view_flipper);
              viewflipper.setAutoStart(true);
              viewflipper.setFlipInterval(300);
              viewflipper.startFlipping();
              Toast.makeText(getActivity(), "Flipping", 300);
              return rootView;
          }
  
          @Override
          public void onAttach(Activity activity) {
              super.onAttach(activity);
              ((HomeActivity) activity).onSectionAttached(getArguments().getInt(ARG_SECTION_NUMBER));
          }
      }
  
  }
  </code></pre>
  
  <p>The associated fragment XML file is coded as:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context="com.example.scientia.HomeActivity$PlaceholderFragment" &gt;
  
  
      &lt;ViewFlipper
          android:id="@+id/view_flipper"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"&gt;
  
          &lt;RelativeLayout
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"&gt;
  
              &lt;ImageView
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:layout_gravity="center"
                  android:adjustViewBounds="true"
                  android:scaleType="centerCrop"
                  android:src="@drawable/school" /&gt;
  
              &lt;TextView
                  style="@style/ImageTitle"
                  android:text="School" /&gt;
          &lt;/RelativeLayout&gt;
  
          &lt;RelativeLayout
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"&gt;
  
              &lt;ImageView
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:layout_gravity="center"
                  android:adjustViewBounds="true"
                  android:scaleType="centerCrop"
                  android:src="@drawable/retina_wood" /&gt;
  
              &lt;TextView
                  style="@style/ImageTitle"
                  android:text="Retina Woods" /&gt;
          &lt;/RelativeLayout&gt;
  
          &lt;RelativeLayout
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"&gt;
  
              &lt;ImageView
                  android:layout_width="fill_parent"
                  android:layout_height="fill_parent"
                  android:layout_gravity="center"
                  android:adjustViewBounds="true"
                  android:scaleType="centerCrop"
                  android:src="@drawable/skulls" /&gt;
  
              &lt;TextView
                  style="@style/ImageTitle"
                  android:text="Skulls" /&gt;
          &lt;/RelativeLayout&gt;
      &lt;/ViewFlipper&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>There are no compilation errors or app crashes but the images are not flipping automatically. Please help!</p>