Good day, you awesome people! Here's my case. I want to refresh the contents of a nested fragment based on an option from the ActionBar. The fragment has a ListView and should display one list if the first ActionBar option is selected and another list if the second option is selected. Let's say I have couple of options in my ActionBar ("All" and "Highlighted").
The desired fragment is in a TabHost, which has a ViewPager.
<TabHost>
<LinearLayout>
<TabWidget
android:id="@android:id/tabs" />
<FrameLayout
android:id="@android:id/tabcontent" />
<android.support.v4.view.ViewPager
android:id="@+id/pager" />
</LinearLayout>
In addition, this is how I add a tab:
mHomeTabsAdapter.addTab(mTabHost.newTabSpec("controls").setIndicator("CONTROLS"), ControlsFragment.class, null);
Since I'm adding the fragment programatically, I cannot give it an id and use the FragmentManager to find it by ID. How do I get a reference to ControlsFragment so I can refresh it from MainActivity's onNavigationItemSelected?
In the ideal situation, I should be able to get a reference to the fragment within onNavigationItemSelected and reinstantiate the adapter that provides the list with items.
I read the communication article (http://developer.android.com/training/basics/fragments/communicating.html) but I'm afraid it's not going to work for me. Anyone got suggestions?