title: Fragment overlapping one on another in android
body: <p>I am fetching data in list view using fragment from MySql and here is a button on the upper side when I used to click on the button it doesn't replace the fragment it overlaps in one to another <a href="https://i.stack.imgur.com/bQQTG.png" rel="nofollow noreferrer">Before</a> and <a href="https://i.stack.imgur.com/Rf6mm.png" rel="nofollow noreferrer">After</a> clicking on button.</p>
  
  <p>Here is the code where I am fetching data in list view format and on the click button i would like to open a new fragment but its overelapping.</p>
  
  <pre><code>public class PlayQuiz extends Fragment{
  
  public String subject;
  
  String myJSON;
  private static final String TAG_RESULTS = "result";  
  private static final String TAG_NAME = "subname";
  
  String selcsub;
  Button b1;
  
  JSONArray peoples = null;
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; personList;
  
  ListView list;
  TextView ss,name;
  
  InputStream is = null;
  String res = null;
  String line = null;
  
  @Override
  public View onCreateView(LayoutInflater inflater,
          @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      View rootView = inflater.inflate(R.layout.play_quiz, container, false);
  
      list = (ListView) rootView.findViewById(R.id.listView);
      ss = (TextView) rootView.findViewById(R.id.textView1);
      b1 = (Button) rootView.findViewById(R.id.button1);
  
      b1.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
              // TODO Auto-generated method stub
                  PlayQuizSubjectWise fragmentManager = new PlayQuizSubjectWise();//.beginTransaction();
                  FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
                  fragmentTransaction.replace(R.id.playsubjectwise, fragmentManager);
                  fragmentTransaction.addToBackStack(null);
                  fragmentTransaction.commit();
          }
      });
  }
  </code></pre>
  
  <p>Main List xml file</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context="com.example.sarvashikshan.PlayQuiz" 
  android:background="#DCDCDC"
  android:id="@+id/playsubjectwise"&gt;
  
  &lt;TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Select Subject"
      android:textAppearance="?android:attr/textAppearanceMedium" /&gt;
  
  &lt;ListView
      android:id="@+id/listView"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/textView1"
      android:layout_below="@+id/textView1"
      android:layout_marginTop="16dp" &gt;
  &lt;/ListView&gt;
  
  &lt;Button
      android:id="@+id/button1"
      style="?android:attr/buttonStyleSmall"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_alignRight="@+id/listView"
      android:layout_marginRight="44dp"
      android:text="Button" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Here is the list 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:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" 
  android:background="#DCDCDC"
  &gt;
  
  &lt;TextView
      android:id="@+id/name"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Large Text"
      android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>PlayQuizSubjectWise XML</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin" &gt;
  
  &lt;TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginTop="31dp"
      android:textAppearance="?android:attr/textAppearanceMedium" /&gt;
  
  &lt;TextView
      android:id="@+id/textView3"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBaseline="@+id/textView1"
      android:layout_alignBottom="@+id/textView1"
      android:layout_marginLeft="35dp"
      android:layout_toRightOf="@+id/textView1"
      android:textAppearance="?android:attr/textAppearanceMedium" /&gt;
  
  &lt;RadioGroup
      android:id="@+id/radioGroup1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/textView1"
      android:layout_below="@+id/textView1"
      android:layout_marginTop="45dp" &gt;
  
      &lt;RadioButton
          android:id="@+id/radio0"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:checked="true" /&gt;
  
      &lt;RadioButton
          android:id="@+id/radio1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
      &lt;RadioButton
          android:id="@+id/radio2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
      &lt;RadioButton
          android:id="@+id/radio3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
  &lt;/RadioGroup&gt;
  
  &lt;Button
      android:id="@+id/button1"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
      android:layout_below="@+id/radioGroup1"
      android:layout_marginTop="78dp"
      android:text="Next" /&gt;
  
  &lt;Button
      android:id="@+id/button2"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/button1"
      android:layout_below="@+id/button1"
      android:text="Finish" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>