title: Change fragment but text reamin android
body: <p>I have this issue: when I change fragment the TextView below remain and the result is 2 TextView.</p>
  
  <p>I explain better:</p>
  
  <p>I have one TextView with a string "hello word"</p>
  
  <p>when I change fragment I want to change the entire page and set another TextView but the result is 2 TextVIew</p>
  
  <p>thanks a lot!</p>
  
  <p>activityMain.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v4.widget.DrawerLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:openDrawer="start"&gt;
  
      &lt;FrameLayout
          android:id="@+id/content_frame"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  
      &lt;include
          layout="@layout/app_bar_main"
          android:layout_width="match_parent"
          android:layout_height="match_parent"/&gt;
  
      &lt;android.support.design.widget.NavigationView
          android:id="@+id/nav_view"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          android:fitsSystemWindows="true"
          app:headerLayout="@layout/nav_header_main"
          app:menu="@menu/activity_main_drawer"/&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>fragment.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:gravity="center"
                android:background="#5ba4e5"
                android:layout_height="match_parent"
                android:id="@+id/fragment"&gt;
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textSize="40px"
          android:textColor="#ffffff"
          android:layout_gravity="center"
          android:id="@+id/fragmentText"
          /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>this in MainActivity for change the fragment:</p>
  
  <pre><code>private void selectItem(int id) {
          // update the main content by replacing fragments
          Fragment fragment = new MyFragment();
  
          FragmentManager fragmentManager = getFragmentManager();
          fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
      }
  </code></pre>
  
  <p>and this is MyFragment.java:</p>
  
  <pre><code>public class MyFragment extends Fragment {
  
      public MyFragment() {
          // Empty constructor required for fragment subclasses
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.fragment, container, false);
          // String planet = getResources().getStringArray(R.array.planets_array)[i];
          String planet = "prova fragment";
          int imageId = getResources().getIdentifier(planet.toLowerCase(Locale.getDefault()),
                  "drawable", getActivity().getPackageName());
          ((TextView) rootView.findViewById(R.id.fragmentText)).setText(planet);
          return rootView;
      }
  }
  </code></pre>