I am trying to use the Swipe View with Tabs in Android and i need to pass some variables to the fragments of the tabs to show a customized content, my problem is that I always have the bundle to 0 so I think I am doing something wrong with the sending of the extras from the fragment container page. this is the code of the fragment and of the main fragment page containing the tabs.
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class
// below).
prof = getIntent().getIntExtra("prof", 0);
id = getIntent().getIntExtra("id", 0);
bund = new Bundle();
bund.putInt("prof", prof);
bund.putInt("id", id);
switch (position) {
case 0:
// Text fragment activity
FragmentOne fragment = new FragmentOne();
fragment.setArguments(bund);
return fragment;
case 1:
// Gallery fragment activity
FragmentTwo fragment2 = new FragmentTwo();
fragment2.setArguments(bund);
return fragment2;
case 2:
//Audio fragment
FragmentThree fragment3 = new FragmentThree();
fragment3.setArguments(bund);
return fragment3;
}
return null;
}
while the fragment code is placed in the onCreateView method
Bundle bundle = getArguments();
if (bundle!=null){
prof = bundle.getInt("prof");
id = bundle.getInt("id");
}
I can read the arguments coming into the fragment container but into the fragment I can't read them, what did I forget?