Question

I got following problem. I got a TabHost with 3 Tabs. I got a List of Data which should be displayed in those 3 Tabs. My problem is how can I access the Data created in the TabHostActivity from my Tabs. I read something about using a Broadcastresceiver but i doubt this is a good way to do.

any help would be great.

Edit:

Okay I guess it will work the way you discribed. But I have to admit that I dont know where to add those Arguments when creating my TabContent like this:

        mTabHost = new FragmentTabHost(getActivity());
    mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.tourenrealtabcontent);


    mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator(getResources().getString(R.string.routes)),
            Tour_fragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator(getResources().getString(R.string.stops)),
            Tourstop_fragment.class, null);
    mTabHost.addTab(mTabHost.newTabSpec("tab3").setIndicator(getResources().getString(R.string.tasks)),
            TourOrder_fragment.class, null);

Thanks alot for your help so far :)

Was it helpful?

Solution

For activities, add an extras bundle to the intent:

Bundle extras = new Bundle();
...
intent.putExtras(extras);

Then retrieve them from your tab's intent:

Bundle extras = getIntent().getExtras();

For fragments, set an arguments bundle:

Fragment fragment = new TabFragment();
Bundle args = new Bundle();
...
fragment.setArguments(args);

Then retrieve the arguments within your fragment:

Bundle args = getArguments();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top