I fail to understand that why is it only me facing such a trivial issue . I googled around and couldn't find much .
My case is simple . I have a layout with a fragment .
<fragment
android:id="@+id/tabs_fragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/header"
android:layout_above="@+id/footer"
class="com.uae.mopw.fragments.TabsFragment" />
I need to send arguments to this fragments , but I CAN'T SEEM TO FIGURE OUT HOW . Had I been making a fragment in the code , I would have had a chance to invoke setarguments before the fragment gets attached to the activity .
However now I dont think I can control what happens when this fragment get attached to the activity because it happens during the initialization of the activity itself .
I try randomly overriding onFragmentAttached and setting the arguments there , however I still couldn't get through with it
I get a Fragment already active exception when I try the above .
Help ?
My activity Oncreate
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String moduleName = null;
if (Utils.getLanguage(this).equals("ar")) {
setContentView(R.layout.activity_application_for_work_to_work_ar);
isArabic=true;
moduleName=ModuleNames.DISTANCE_MEASUREMENT_SERVICE_AR;
} else {
setContentView(R.layout.activity_application_for_work_to_work);
isArabic=false;
moduleName=ModuleNames.DISTANCE_MEASUREMENT_SERVICE;
}
/*init header*/
new Header(this,HeaderTypes.HEADER_INTERNAL,moduleName);
/*take out bundle from intent*/
Bundle args = this.getIntent().getBundleExtra(ModuleNames.DISTANCE_MEASUREMENT_SERVICE);
/*Obtain fragment reference*/
fragment=(TabsFragment)getFragmentManager().findFragmentById(R.id.tabs_fragment);
fragment.setArguments(new Bundle());
}