title: Navigating from one fragment via another via onClick, android
body: <p>How do you navigate from one fragment to another, where one fragment extends the other? I want to navigate from the child fragment to the parent fragment via a button. Since the child fragment inherits from the parent fragment, they use the same onCreate method, and therefore also inflating the same view. I have tried to use replace, but I'm not able to find the id of the fragment that should be replaced.</p>
  <pre><code> Button button = new Button(getActivity());
          button.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Fragment fragment = new ListFragment();
                  FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
                  FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                  fragmentTransaction.replace(id,fragment);
                  fragmentTransaction.addToBackStack(null);
                  fragmentTransaction.commit();
              }
          });
  </code></pre>