Question

The use of this tutorial is very clear to me however I am using the Actionbar.tablistner interface. How can I pass variables(strings) from fragment to fragment using this interface?

public class MainActivity extends FragmentActivity implements ActionBar.TabListener
{
}
Was it helpful?

Solution

Create an interface with a method which accepts any variable (e.g. String). Something like this:

public interface TabClickedListener {
   public void passParam(String var);
}

Implement this interface in your Activity. From the Actionbar.tablistener onTabSelected() method call the above interface method (on the activity instance you have) passing whatever value you would like. Once you receive this value in your Activity you can pass this to a different Fragment.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top