I have developed an application with tab using FragmentActivity. How can I pass some extra data while calling fragments and how can I get that data in fragment class?
The code for adding tab is given below. Fragment class is specified directly within it.
mTabManager.addTab(mTabHost.newTabSpec("simple").setIndicator("Simple"),
DetailFragment.class, null);
In this case how can I pass some data to fragment class. Please any one help to do this.
You can check here: http://developer.android.com/reference/android/app/TabActivity.html
In that example they show how to use the FragmentTabs with the support package, if you look down you can see that they implement their own TabManager class. There they implement the function addTab:
There you create the object TabInfo, previously defined as:
you can put data on that bundle (args). Now if you look at the overridden function onTabChanged you can see how the bundle is passed on the instantiation of the fragment(newTab.args):
Finally you can access that bundle from the fragment itself calling getArguments ()
hope that helps.