title: Start Fragment from RecyclerView adapter
body: <p>I'm tring to start a new <code>Fragment</code> from my adapter of <code>RecyclerView</code>. This is the code.</p>
  
  <pre><code>@Override
  public AdapterDrawer.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  
      if(viewType == ITEM) {
          view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_item_drawer, parent, false);
          viewHolder = new ViewHolder(view, viewType);
  
          return viewHolder; 
  
      } else if (viewType == HEADER) {
          view = LayoutInflater.from(parent.getContext()).inflate(R.layout.header, parent, false); 
          viewHolder = new ViewHolder(view, viewType);
  
          return viewHolder;    
      }
  
      return null;
  }  
  
  public ViewHolder(View view, int viewType) {             
      super(view);
  
      switch(viewType) {
      case ITEM:
          // ..... code
  
          break;
      case HEADER:
          //code.... findiewById ecc
  
          mycardView.setOnClickListener(new OnClickListener() {
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  Bundle bundle = new Bundle();
                  bundle.putString("Code", "Value");
                  Fragment fragment = new MyFragment();
                  fragment.setArguments(bundle);
                  ((ActionBarActivity)context).getFragmentManager().beginTransaction().replace(R.id.container, fragment).commit();
              }                   
          });
  
          break;
  </code></pre>
  
  <p>When I click on <code>CardView</code> I got this error</p>
  
  <pre><code>05-23 08:35:04.861: E/AndroidRuntime(24568): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at android.view.ViewGroup.addViewInner(ViewGroup.java:3936)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at android.view.ViewGroup.addView(ViewGroup.java:3786)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at android.view.ViewGroup.addView(ViewGroup.java:3727)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at android.view.ViewGroup.addView(ViewGroup.java:3700)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:905)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at android.app.BackStackRecord.run(BackStackRecord.java:834)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1452)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at android.app.FragmentManagerImpl$1.run(FragmentManager.java:447)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at android.os.Handler.handleCallback(Handler.java:739)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at android.os.Handler.dispatchMessage(Handler.java:95)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at android.os.Looper.loop(Looper.java:135)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at android.app.ActivityThread.main(ActivityThread.java:5254)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at java.lang.reflect.Method.invoke(Native Method)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at java.lang.reflect.Method.invoke(Method.java:372)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
  05-23 08:35:04.861: E/AndroidRuntime(24568):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
  </code></pre>
  
  <p>Why? How can i solve? My <code>RecyclerView</code> is inside <code>Fragment</code>.</p>