i had declare framgmentActivity like below:
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
mTabHost.addTab(mTabHost.newTabSpec("basic").setIndicator("Basic",getResources().getDrawable(R.drawable.ic_launcher)),BasicProductFragment.class, null);
mTabHost.addTab(mTabHost.newTabSpec("taxes").setIndicator("Taxes",getResources().getDrawable(R.drawable.ic_launcher)),TaxesProductFragment.class, null);
mTabHost.addTab(mTabHost.newTabSpec("price").setIndicator("Price",getResources().getDrawable(R.drawable.ic_launcher)),PriceProductFragment.class, null);
mTabHost.addTab(mTabHost.newTabSpec("stock").setIndicator("Stock",getResources().getDrawable(R.drawable.ic_launcher)),StockProductFragment.class, null);
Now in all frament i had declare two or three edittext now in this activity, i want to get data from that all edittext from diffrent frangment tab.
A singleton class could help solve your problem.
public class GlobalApp {
private static GlobalApp instance = new GlobalApp();
private GlobalApp() {}
public static 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With