I followed http://developer.android.com/guide/topics/ui/actionbar.html#Tabs
It uses the following code to add Tab.
Tab tab = actionBar.newTab()
.setText(R.string.artist)
.setTabListener(new TabListener<ArtistFragment>(
this, "artist", ArtistFragment.class));
actionBar.addTab(tab);
I want to supply argument to the fragment's constructor or call myInit(myVariableList) method on the fragment instance before showing the tab for the first time.
How can I do that?
You can use
tab.setTag()
to link an arbitrary object to the tab. If you can putmyVariableList
into aBundle
, you can achieve a simple solution by doing the following --Then, in your
onTabSelected
callback, send theBundle
when you instantiate your fragment --You should then be able to access your
Bundle
during the fragment lifecycle usinggetArguments()