title: Passing data between two fragments
body: <p>I have two fragments, declared in separate classes - AFragment and BFragment. My MainActivity looks somewhat like this:</p>
  
  <pre><code>public class MainActivity extends SherlockFragmentActivity implements ActionBar.TabListener 
  {       
      @Override
      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  
      ActionBar.Tab firstTab = getSupportActionBar().newTab().setText("Fragment A");           
      ActionBar.Tab secondTab = getSupportActionBar().newTab().setText("Fragment B");
  
      SherlockFragment firstFragment = new AFragment();
      SherlockFragment secondFragment = new BFragment();
  
      firstTab.setTabListener(this);
      secondTab.setTabListener(this);
  
      getSupportActionBar().addTab(firstTab);
      getSupportActionBar().addTab(secondTab);
      }
  
      @Override
      public void onTabReselected(Tab tab, FragmentTransaction ft) {
      }
  
      @Override
      public void onTabSelected(Tab tab, FragmentTransaction ft) {
      switch (tab.getPosition())
      {
      case 0:
          ft.replace(R.id.fragment_container, new AFragment());
          break;
      case 1:
          ft.replace(R.id.fragment_container, new BFragment());
          break;
      }
      Toast.makeText(this, tab.getText(), Toast.LENGTH_LONG).show();      
      }
      @Override
      public void onTabUnselected(Tab tab, FragmentTransaction ft) {
      }
  }
  </code></pre>
  
  <p>My question is, how do I pass a variable - say an integer - between my two fragments? For example, I'd press a button in the first fragment, and a particular integer would appear in a TextView in the second one.</p>