title: Getting Reference to Fragment - Google Slidingtablayout
body: <p>I'm replacing <code>("Updating")</code> an application that used <code>ActionBar.NAVIGATION_MODE_TABS</code> that's been deprecated.</p>
  
  <p>That deprecated code is being replaced with Google's</p>
  
  <p><a href="https://github.com/google/iosched/blob/master/android/src/main/java/com/google/samples/apps/iosched/ui/widget/SlidingTabLayout.java" rel="nofollow">SlidingTabLayout.java</a></p>
  
  <p><a href="https://github.com/google/iosched/blob/0a90bf8e6b90e9226f8c15b34eb7b1e4bf6d632e/android/src/main/java/com/google/samples/apps/iosched/ui/widget/SlidingTabStrip.java" rel="nofollow">SlidingTabStrip.java</a></p>
  
  <p>For an application with <code>5 Tabs</code>, and a <code>ViewPager</code>. Each tab has it's own <code>android.support.v4.app.Fragment</code> associated with it that's established in a <code>FragmentPageAdapter</code> <code>getItem()</code> method. Each "newInstance" of the Fragment is associated with a single layout file.</p>
  
  <p>When the User either swipes to the desired page, or selects one of the tabs, I want to reference the specific Fragment (<strong>that finally comes into focus</strong>) because each Fragment has different data associated with it. </p>
  
  <p>So for example, think of each Fragment representing a different business location, with it's own specific address.</p>
  
  <p>So again, when the User selects a Tab or "swipes to" ( that represents a specific business location), I need to set the Fragments <code>Textview</code> elements with the specific business address information. There's also data that will be displayed on the Fragment that's dynamic. Briefly, there's calls made to the cloud to get data that's displayed on the Fragment for each Fragment.</p>
  
  <p>For the life of me, I can't seem to get the final or correct Fragment. I've tried everything I can think of or makes sense to me. For instance, I've tried getting a handle to the "final" or "destination" fragment in the</p>
  
  <p><code>onPageScrolled()</code> method of the <code>SlidingTabLayout</code> class,</p>
  
  <p><code>onPageSelected()</code> method of the <code>SlidingTabLayout</code> class,</p>
  
  <p>or <code>getItem()</code> method of the <code>FragmentPageAdapter</code> class. </p>
  
  <p>I do get a reference to a Fragment. Set the TextView elements of the Fragment, but then those Elements get blanked out in the end. It's as though the Fragment I thought was the correct one, is being replaced with another. If that makes sense. I say that, because when I'm in debug mode, I can see the Text I set, but then when I continue to step through (or at the very end after all executing code has finished), the text disappears. It seems I'm referencing the current Fragment or the one in Focus, but then the "target" or "destination" Fragment comes into view and my changes in Text are gone. Because I never really set them in the correct Fragment. Follow?</p>
  
  <p>I'm lost...spent Waaaaaaaay to much time on this!</p>