I want send data between fragment. the first fragment (name is FragmentTabs) contains tow tabs (fragments too) FragTab1 and FragTab2.
i want send the data between FragmentTabs and FragTab1
Here is my code:
in FragmentTabs :
mTabHost = (FragmentTabHost) rootView.findViewById(android.R.id.tabhost);
mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.contenttab);
mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator("tab 1"),
fragment(id).getClass(), null);
the function fragment:
private Fragment fragment(String id){
FragTab1 Ftab1 = new FragTab1();
Bundle dataBndl = new Bundle();
dataBndl.putString("id", id);
Ftab1.setArguments(dataBndl);
return Ftab1 ;
}
in FragTab1:
Bundle bndl = getArguments();
getId = bndl.getString("id");
The error is caused at the last statement: getId = bndl.getString("id");
Use Bundle to send String:
In onCreateView of the new Fragment: