title: Hiding Fragment and showing other Fragment not working
body: <p>I am working on an Android App and trying to hide one Fragment and showing another Fragment. I have been stuck in this for two days now, as I tried every possibility, googled a lot - however it is not delivering the desired result:</p>
  
  <pre><code> package com.cubic.cumo.rmvsmt.fragments;
  
      import android.content.Intent;
      import android.os.Bundle;
      import android.view.LayoutInflater;
      import android.view.View;
      import android.view.ViewGroup;
      import android.widget.Button;
      import android.widget.TextView;
  
      import com.cubic.cumo.basislib.cibo.Cibo;
      import com.cubic.cumo.basislib.cibo.CiboJourney;
      import com.cubic.cumo.basislib.common.CumoTextTools;
      import com.cubic.cumo.basislib.fragments.BasisFragment;
      import com.cubic.cumo.basislib.fragments.FragmentCreator;
      import com.cubic.cumo.basislib.fragments.UiContent;
      import com.cubic.cumo.basislib.model.StopInfo;
      import com.cubic.cumo.basislib.model.TicketInfo;
      import com.cubic.cumo.rmvsmt.MainActivity;
      import com.cubic.cumo.rmvsmt.R;
  
      public class RMVCiboJourneyFragment extends BasisFragment {
  
          /**
           * Fragment creator for the RMV Station Selector.
           */
          public static class Creator extends FragmentCreator {
  
              @Override
              public BasisFragment create(String name, Bundle args) {
                  RMVCiboJourneyFragment f = new RMVCiboJourneyFragment();
                  f.setArguments(args);
                  return f;
              }
          }
  
          private View mContentNoJourney;
          private View mContentJourney;
          private TextView mOriginTextView;
          private TextView mDestinationTextView;
          private TextView mDepartureTextView;
          private TextView mArrivalTextView;
  
          private CiboJourney mJourney;
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                   Bundle savedInstanceState) {
              // Inflate the layout for this fragment
              View view = inflater.inflate(R.layout.fragment_cibo_journey, container, false);
  
              mContentJourney =       view.findViewById(R.id.content_journey);
              mContentNoJourney =     view.findViewById(R.id.content_no_journey);
              mOriginTextView =       view.findViewById(R.id.cibo_journey_origin_text);
              mDestinationTextView =  view.findViewById(R.id.cibo_journey_destination_text);
              mDepartureTextView =    view.findViewById(R.id.cibo_journey_departure_text);
              mArrivalTextView =      view.findViewById(R.id.cibo_journey_arrival_text);
  
              Button okButton = view.findViewById(R.id.cibo_ok_button);
              okButton.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
  
                      getActivity().setResult(0);
                      getActivity().finish();
                  }
              });
              Button onReportErrorButton = (Button) view.findViewById(R.id.cibo_report_error_button);
              onReportErrorButton.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      getActivity().setResult(1);
                      getActivity().finish();
                  }
              });
  
              Bundle bundle = getArguments();
              try {
                  mJourney = (CiboJourney) bundle.getSerializable("DATA");
              }
              catch (Exception e) {
                  // This will catch any exception, because they are all descended from Exception
                  System.out.println("Error " + e.getMessage());
                  return null;
              }
  
              if (mJourney != null &amp;&amp; mJourney.arrival != null &amp;&amp; mJourney.departure != null &amp;&amp; mJourney.origin != null &amp;&amp; mJourney.destination != null) {
                  mContentJourney.setVisibility(View.VISIBLE);
                  mContentNoJourney.setVisibility(View.GONE);
  
                  mOriginTextView.setText(mJourney.origin.getName());
                  mDepartureTextView.setText(getString(R.string.cibo_start_station, CumoTextTools.formatDate(mJourney.departure, CumoTextTools.CumoDateFormat.TIME)));
                  mDestinationTextView.setText(mJourney.destination.getName());
                  mArrivalTextView.setText(getString(R.string.cibo_dest_station, CumoTextTools.formatDate(mJourney.arrival, CumoTextTools.CumoDateFormat.TIME)));
              } else {
                  mContentJourney.setVisibility(View.GONE);
                  mContentNoJourney.setVisibility(View.VISIBLE);
                  this.getId();
              }
  
              return view;
          }
  
  
          @Override
          public void showContent(UiContent content) {
  
          }
  
          @Override
          public boolean onBackPressed() {
              return false;
          }
      }
  </code></pre>
  
  <p>This is the View that should show up in the other Fragment: </p>
  
  <pre><code>Bundle bundle = getArguments();
      try {
          mJourney = (CiboJourney) bundle.getSerializable("DATA");
      }
      catch (Exception e) {
          // This will catch any exception, because they are all descended from Exception
          System.out.println("Error " + e.getMessage());
          return null;
      }
  
      if (mJourney != null &amp;&amp; mJourney.arrival != null &amp;&amp; mJourney.departure != null &amp;&amp; mJourney.origin != null &amp;&amp; mJourney.destination != null) {
          mContentJourney.setVisibility(View.VISIBLE);
          mContentNoJourney.setVisibility(View.GONE);
  
          mOriginTextView.setText(mJourney.origin.getName());
          mDepartureTextView.setText(getString(R.string.cibo_start_station, CumoTextTools.formatDate(mJourney.departure, CumoTextTools.CumoDateFormat.TIME)));
          mDestinationTextView.setText(mJourney.destination.getName());
          mArrivalTextView.setText(getString(R.string.cibo_dest_station, CumoTextTools.formatDate(mJourney.arrival, CumoTextTools.CumoDateFormat.TIME)));
      } else {
          mContentJourney.setVisibility(View.GONE);
          mContentNoJourney.setVisibility(View.VISIBLE);
          this.getId();
      }
  
      return view;
  }
  </code></pre>
  
  <p>This is the code in the other Fragment that should do mContentNoJourney.setVisibility(View.VISIBLE) or at least show the corresponding view: </p>
  
  <pre><code> if ((backButton != null) &amp;&amp; (closeButton != null)) {
                      backButton.setVisibility(View.INVISIBLE);
                      closeButton.setOnClickListener(new View.OnClickListener() {
                          @Override
                          public void onClick(View v) {
                              Log.d(this.getClass().getName(), "closeButton geklickt");
  
                              RMVCiboJourneyFragment nextFrag= new RMVCiboJourneyFragment();
                              getActivity().getSupportFragmentManager().beginTransaction()
                                      .replace(R.id.WebContentWebView, nextFrag, "mContentNoJourney")
                                      .addToBackStack(null)
                                      .commit();
                              //mContentNoJourney =     view.findViewById(R.id.content_no_journey);
                              //mContentNoJourney.setVisibility(View.VISIBLE);
                               /*     *//*      List&lt;Fragment&gt; fragmentList = getFragmentManager().getFragments();
                  FragmentManager fragmentManager = getFragmentManager();
                              FragmentFactory.instance().registerCreator(FragmentFactory.CiboJourney, new RMVCiboJourneyFragment.Creator());
                              FragmentTransaction transaction;
                              transaction = fragmentManager.beginTransaction();*//*
                              //transaction.replace(R.id.container,R.id.content_no_journey);
                              transaction.addToBackStack(null);
                              transaction.commit();*/
  
                           /*   Fragment fragment = getFragmentManager().findFragmentByTag();
                              if(fragment != null)
                                  getFragmentManager().beginTransaction().remove(fragment).commit();*/
  
                              // FragmentManager fm = getActivity().getFragmentManager();
                              // fm.popBackStack();
                              // You might have to access all the fragments by their tag,
                              // in which case just follow the line below to remove the fragment
                              /*if (fragmentList == null) {
                                  // code that handles no existing fragments
                              }
                              for (Fragment frag : fragmentList )
                              {
                                  // To save any of the fragments, add this check
                                  // a tag can be added as a third parameter to the fragment when you commit it
                                 *//* if (frag.getTag().equals("&lt;tag-name")) {
                                      continue;
                                  }*//*
                              getFragmentManager().beginTransaction().remove(frag).commit();
                              }
  
                              Fragment id = getFragmentManager().findFragmentById(R.id.container);
                              if(getFragmentManager().findFragmentById(R.id.container) == null) {
                                  getFragmentManager().beginTransaction()
                                          .replace(R.id.titlebar, id)
                                          .commit();
                              }
                              RMVCiboJourneyFragment journeyFragment = new RMVCiboJourneyFragment();
                              getFragmentManager().beginTransaction().replace(R.id.content_no_journey, journeyFragment).commit();*/
                              //mContentNoJourney = getFragmentManager().popBackStackImmediate(R.id.content_no_journey);
                              //mContentNoJourney.setVisibility(View.VISIBLE);
                          }
                      });
                  }
  </code></pre>
  
  <p>The problem is, that none of what I have commented out is working. </p>
  
  <p>I am basically just trying to shut down a Fragment in a Webview and open up another Fragment, which is not working. </p>
  
  <p>Any hints or help would be very much appreciated, thanks in advance! </p>