beachdogvet
Newbie
I'm replacing ("Updating") an application that used ActionBar.NAVIGATION_MODE_TABS that's been deprecated.
That deprecated code is being replaced with Google's
for an application with 5 Tabs, and a ViewPager. Each tab has it's own android.support.v4.app.Fragment associated with it that's established in a FragmentPageAdapter getItem() method. Each "newInstance" of the Fragment is associated with a single layout file.
When the User either swipes to the desired page, or selects one of the tabs, I want to reference the specific Fragment (that finally comes into focus) because each Fragment has different data associated with it. So for example, think of each Fragment representing a different business location, with it's own specific address.
So again, when the User selects a Tab or "swipes to" ( that represents a specific business location), I need to set the Fragments TextView elements with the specific business address information.
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 "current" fragment in the
onPageScrolled() method of the SlidingTabLayout class,
onPageSelected() method of the SlidingTabLayout class,
or getItem() method of the FragmentPageAdapter class.
I get a reference to a Fragment......one I believe is the correct Fragment. Set the TextView elements, 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.
I'm lost...spent Waaaaaaaay to much time on this!
That deprecated code is being replaced with Google's
for an application with 5 Tabs, and a ViewPager. Each tab has it's own android.support.v4.app.Fragment associated with it that's established in a FragmentPageAdapter getItem() method. Each "newInstance" of the Fragment is associated with a single layout file.
When the User either swipes to the desired page, or selects one of the tabs, I want to reference the specific Fragment (that finally comes into focus) because each Fragment has different data associated with it. So for example, think of each Fragment representing a different business location, with it's own specific address.
So again, when the User selects a Tab or "swipes to" ( that represents a specific business location), I need to set the Fragments TextView elements with the specific business address information.
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 "current" fragment in the
onPageScrolled() method of the SlidingTabLayout class,
onPageSelected() method of the SlidingTabLayout class,
or getItem() method of the FragmentPageAdapter class.
I get a reference to a Fragment......one I believe is the correct Fragment. Set the TextView elements, 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.
I'm lost...spent Waaaaaaaay to much time on this!