title: FragmentPagerAdapter is not removing items (Fragments) correctly
body: <p>I have implemented the <code>FragmentPagerAdapter</code> and and using a <code>List&lt;Fragment&gt;</code> to hold all fragments for my <code>ViewPager</code> to display. On <code>addItem()</code> I simply add an instantiated <code>Fragment</code> and then call <code>notifyDataSetChanged()</code>. I am not sure if this is necessary or not. </p>
  
  <p>My problem simply...
  start with fragment 1 </p>
  
  <pre><code>[Fragment 1] 
  </code></pre>
  
  <p>add new Fragment 2    </p>
  
  <pre><code>[Fragment 1] [Fragment 2]
  </code></pre>
  
  <p>remove Fragment 2     </p>
  
  <pre><code>[Fragment 1]
  </code></pre>
  
  <p>add new Fragment 3    </p>
  
  <pre><code>[Fragment 1] [Fragment 2]
  </code></pre>
  
  <p>When adding new fragments everything seems great. Once I remove a fragment and then add a newly instantiated fragment the old fragment is still displayed. When i go a <code>.getClass.getName()</code> it is giving me Fragment 3's name however I still see Fragment 2. </p>
  
  <p>I believe this might be an issue with <code>instantiateItem()</code> or such but I thought the adapter was to handle that for us. Any suggestions would be great. </p>
  
  <p>adapter code...</p>
  
  <pre><code>public class MyPagerAdapter extends FragmentPagerAdapter {
  public final ArrayList&lt;Fragment&gt; screens2 = new ArrayList&lt;Fragment&gt;();
  
  
  private Context context;
  
  public MyPagerAdapter(FragmentManager fm, Context context) {
      super(fm);
      this.context = context;
  }
  
  public void removeType(String name){
      for(Fragment f: screens2){
          if(f.getClass().getName().contains(name)){ screens2.remove(f); return; }
      }
      this.notifyDataSetChanged();
  }
  
  public boolean addSt(String tag, Class&lt;?&gt; clss, Bundle args){
      if(clss==null) return false;
      if(!clss.getName().contains("St")) return false; 
      if(!args.containsKey("cId")) return false;
      boolean has = false;
      boolean hasAlready = false;
      for(Fragment tab: screens2){
          if(tab.getClass().getName().contains("St")){
              has = true;
              if(tab.getArguments().containsKey("cId"))
                  if(tab.getArguments().getLong("cId") == args.getLong("cId")){
                      hasAlready = true;
                  }
              if(!hasAlready){
                  // exists but is different so replace
                  screens2.remove(tab);
                  this.addScreen(tag, clss, args, C.PAGE_ST);
                  // if returned true then it notifies dataset
                  return true;
              }
          }
          hasAlready = false;
      }
  
      if(!has){ 
          // no st yet exist in adapter
          this.addScreen(tag, clss, args, C.PAGE_ST);
          return true;
      }
  
      return false;
  }
  
  public boolean removeCCreate(){
      this.removeType("Create");  
      return false;
  }
  
  @Override
  public int getItemPosition(Object object) {
  
     return POSITION_NONE; //To make notifyDataSetChanged() do something
    }
  
  public void addCCreate(){
      this.removeCCreate();
      Log.w("addding c", " ");
      this.addScreen("Create C",  CreateCFragment.class, null, C.PAGE_CREATE_C);
  }
  
  public void addScreen(String tag, Class&lt;?&gt; clss, Bundle args, int type){
      if(clss!=null){
          screens2.add(Fragment.instantiate(context, clss.getName(), args));
      }
  }
  
  @Override
  public int getCount() {
      return screens2.size();
  }
  
  
  @Override
  public Fragment getItem(int position) {
      return screens2.get(position); 
  }
  
  }
  </code></pre>
  
  <p>I realize the code uses some "ghetto" means of determining the fragment type however I wrote this code strictly for testing functionality. Any help or ideas would be great as it seems that not many people ventured into the world of <code>FragmentPagerAdapter</code>s.</p>