title: Passing data between fragments without newly instantiating the receiving fragment
body: <p>passing data between fragments is a common scenario, answered f.i. <a href="http://manishkpr.webheavens.com/android-passing-data-between-fragments/" rel="nofollow noreferrer">here</a>. You build an interface that is implemented by the fragments' host activity. In the activity's implementation method, the receiving fragment is newly instantiated, with the new transmitted data as a Bundle.</p>
  
  <p>The problem: I'd need an old instance of the receiving fragment with the new information ADDED, not a fresh instance.</p>
  
  <p>I have a main activity with one fragment container. The first fragment is a form where the user must fill in some data. A certain button opens the second fragment where an item from a treeview is selected. The selection must be transmitted to a textfield in the first fragment. Of course, the entries in the first fragment can never be deleted.</p>
  
  <p>I could put all the input fields' content in an interface and refill them into a new instance of firstFragment, but that seems rather stupid to me.</p>
  
  <p>Is the "one-container-multiple-fragments"-pattern applicable in my case? Or should I use a second fragment container and turn the visibilty on and off?</p>
  
  <p>startactivityforresult unfortunately does not apply for fragments.</p>
  
  <p>Thanks a lot!  </p>
  
  <p>edit: This is the code of my main activity.</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      //init Databinding
      oBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
  
      setSupportActionBar(oBinding.toolbar);
  
      if(oBinding.mainContainer != null){
  
          //are we restoring the instance state?
          if(savedInstanceState != null){
              return; //yes - do nothing 
          }
  
          MainFragment oMainFragment = new MainFragment();
          getSupportFragmentManager()
                  .beginTransaction()
                  .add(oBinding.mainContainer.getId(), oMainFragment)
                  .commit();
          }
      }
  
  @Override
      public void onCatButtonClicked() {
          NewCatFragment oSubFragment = new NewCatFragment();
          getSupportFragmentManager()
                  .beginTransaction()
                  .replace(oBinding.mainContainer.getId(), oSubFragment)
                  .addToBackStack(null)
                  .commit();
      }
  
  @Override
  public void onItemSelected(String sItem) {
  //here i'd like old instance qith just some new stuff
      MainFragment oMainFragment = new MainFragment();
      Bundle oBundle = new Bundle();
      oBundle.putString("ITEM", sItem);
      oMainFragment.setArguments(oBundle);
      getSupportFragmentManager()
              .beginTransaction()
              .replace(oBinding.mainContainer.getId(), oMainFragment)
              .addToBackStack(null)
              .commit();
  }
  </code></pre>