title: Setting Actionbar title with a ViewPager
body: <p>My app has a <code>ListView</code> on startup.  The user can either manually select an item in the <code>ListView</code> to go to a details screen or swipe using a <code>ViewPager</code> between the different details screens.  The <code>ViewPager's</code> fragments are setup like this:</p>
  
  <pre>
  Listing
  Detail 1
  Detail 2
  Detail 3
  Detail 4
  ...
  </pre>
  
  <p>It's my understanding, when the Listing fragment is loaded, the <code>ViewPager</code> will execute Detail 1's code, for performance.  The same when Detail 1 is loaded, Detail 2's code will execute.</p>
  
  <p>The problem I'm running into is that I'm setting the title of each detail fragment in <code>onActivityCreated</code>, however, when the Listing fragment is loaded, it is displaying Detail 1's title.  So I moved the code to <code>onPageSelected</code> of the <code>ViewPager</code>, which works if the user is swiping, but if the user manually selects an item in the <code>ListView</code> the title is never set.</p>
  
  <p>I'm not sure if there is an event that is only fired when a user manually selects an item in the <code>ListView</code> and not when they are swiping or if I need to rethink my apps' setup.  For example, instead of using this code in the Listing fragment's <code>onListItemClick</code> event:</p>
  
  <pre><code>final Intent listing = new Intent(getActivity().getApplicationContext(), Details.class);
  startActivity(listing);
  </code></pre>
  
  <p>I need to somehow use the <code>ViewPager</code>.</p>
  
  <pre><code>mViewPager = (ViewPager)findViewById(R.id.viewpager);  
  mMyFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager());  
  mViewPager.setAdapter(mMyFragmentPagerAdapter);
  mViewPager.setSaveEnabled(false);
  mViewPager.setOnPageChangeListener(new OnPageChangeListener() {
  
      @Override
      public void onPageSelected(int position) {      
          String title = GetTitle(position);
          getSupportActionBar().setTitle(title);                  
      }
  
      @Override
      public void onPageScrolled(int position, float offset, int offsetPixel) {
      }
  
      @Override
      public void onPageScrollStateChanged(int state) {
  
      }
  });
  </code></pre>