Skip to content Skip to sidebar Skip to footer

Android Get Value From All Fragment Tab

i had declare framgmentActivity like below: mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabc

Solution 1:

A singleton class could help solve your problem.

publicclassGlobalApp {
    privatestatic GlobalApp instance = new GlobalApp();

    privateGlobalApp() {}

    publicstatic GlobalApp getInstance() {
        return instance;
    }

    public Details details = new Details ();

}

Then use in your Fragment class like this..

GlobalApp.getInstance().details.setSomeData("something");

Now you can get all the values which are changed in those fragment in your mainActivity

 GlobalApp.getInstance().details.getSomeData();

I have given the same answer for another question which has some relation to this.

Communicative Between Fragments on Android

Post a Comment for "Android Get Value From All Fragment Tab"