title: Android Fragment refresh doesn't work
body: <p>I'm trying to sort my picture list in a GridView which is on a seperate fragment.
  The issue is when I remove old fragment and add new fragment the old one stil prevails and the new one prints top of it.
  this is how I refresh the View.</p>
  
  <pre><code>Bundle bundle = new Bundle();
      bundle.putString("sort", sort);
  
      android.support.v4.app.Fragment frg = new MainActivityFragment();
      android.support.v4.app.Fragment currentFrg = getSupportFragmentManager().findFragmentById(R.id.fragment);
      final android.support.v4.app.FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
      ft.remove(currentFrg);
      frg.setArguments(bundle);
      ft.add(R.id.fragment, frg).commit();
  </code></pre>
  
  <p>Please give me some hint regarding this.</p>
  
  <p>this is the Fragment class</p>
  
  <pre><code>public class MainActivityFragment extends Fragment {
  
  private MovieAdaptor movieAdaptor;
  
  GridView gridView;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
     View rootView = inflater.inflate(R.layout.fragment_main, container, false);
  
     ImageView iconView = (ImageView) this.getActivity().findViewById(R.id.list_item_icon);
  
     FetchMovieTask task = new FetchMovieTask();
      String sort = "";
      Bundle bundle = this.getArguments();
      if (bundle != null) {
          sort = bundle.getString("sort", "popularity.desc");
      }
  
      try {
          movieAdaptor    = new MovieAdaptor(this.getActivity(), (List&lt;Movie&gt;) task.execute(sort).get() );
      } catch (InterruptedException e) {
          e.printStackTrace();
      } catch (ExecutionException e) {
          e.printStackTrace();
      }
  
  
      gridView = (GridView) rootView.findViewById(R.id.gridview);
  
      if(movieAdaptor != null){
  
          Log.e("MOVIE_DATA", "movieAdaptor IS NOT NULL ");
          gridView.setAdapter(movieAdaptor);
  
      }else {
          Log.e("MOVIE_DATA", "movieAdaptor IS NULL");
      }
  
      return rootView;
  }
  }
  </code></pre>
  
  <p>and in MainActivity when the option menu changes this transaction calls;
  this is the regarding code;</p>
  
  <pre><code> @Override
  public boolean onOptionsItemSelected(MenuItem item) {
  
      int id = item.getItemId();
  
      String sort = "";
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_sort_rating) {
          sort = "vote_average.desc";
  
      }
  
      if(id == R.id.action_sort_popularity){
          sort = "popularity.desc";
  
      }
  
      if(id == R.id.action_sort_release_date){
          sort = "release_date.desc";
  
      }
  
      Bundle bundle = new Bundle();
      bundle.putString("sort", sort);
      android.support.v4.app.Fragment frg = new MainActivityFragment();
      final android.support.v4.app.FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
      frg.setArguments(bundle);
      ft.replace(R.id.fragment, frg).commit();
  
  
  
      return  true;
  
      //return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>this is my fragment_main.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:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  android:paddingBottom="@dimen/activity_vertical_margin"
  tools:context=".MainActivity$MainActivityFragment"&gt;
  
  
  &lt;GridView
      android:id="@+id/gridview"
      android:numColumns="2"
      android:gravity="top"
      android:columnWidth="50dp"
      android:stretchMode="columnWidth"
      android:layout_width="fill_parent"
      android:layout_height="match_parent"
      android:verticalSpacing="0dp"
      android:horizontalSpacing="0dp"
     &gt;
  
  &lt;/GridView&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>activity_main.xml</p>
  
  <pre><code>&lt;fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/fragment"
        android:name="com.alpha0.popular_movies_app.MainActivityFragment"
        tools:layout="@layout/fragment_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/&gt;
  </code></pre>