title: YouTubePlayerFragment inside ReyclerView
body: <p>I have a RecyclerView with CardViews inside it. I want each CardView to have its own YouTubePlayerFragment. Even if they can't all be active at once, I can't even seem to instantiate the YouTubePlayerFragment in any CardView but the first in the RecyclerView. When clicking the button on the card that's supposed to set up the YouTubePlayerFragment, it always sets it up on the first card, even if I've clicked the second card. Is what I'm trying to do possible?</p>
  
  <p>Here are the relevant parts of code:</p>
  
  <p><strong>Holder for the fragment in CardView XML:</strong> (using fragment directly in xml was giving binary XML exception, probably due to fragment within a fragment somewhere along the line)</p>
  
  <pre><code>&lt;FrameLayout
          android:id="@+id/youtube_holder"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_alignParentTop="true"
          android:layout_alignLeft="@+id/layout_video_thumbnail"
          android:layout_alignStart="@+id/layout_video_thumbnail"
          android:layout_alignRight="@+id/layout_video_thumbnail"
          android:layout_alignEnd="@+id/layout_video_thumbnail"
          android:visibility="visible"/&gt;
  </code></pre>
  
  <p><strong>ViewHolder:</strong></p>
  
  <pre><code>public class VideoViewHolder extends RecyclerView.ViewHolder {
  
  protected FrameLayout containerYouTubePlayer;
  protected TextView textViewTitle;
  protected ImageView imageViewThumbNail;
  protected Button buttonPreview, buttonSet;
  protected Context activityContext;
  
  public VideoViewHolder(Context activityContext, View itemView) {
      super(itemView);
  
      this.activityContext = activityContext;
      containerYouTubePlayer = (FrameLayout) itemView.findViewById(R.id.youtube_holder);
      textViewTitle = (TextView) itemView.findViewById(R.id.textView_title);
      imageViewThumbNail = (ImageView) itemView.findViewById(R.id.imageView_video_thumbnail);
      buttonPreview = (Button) itemView.findViewById(R.id.button_preview);
      buttonSet = (Button) itemView.findViewById(R.id.button_set);
  }
  }
  </code></pre>
  
  <p><strong>RecyclerView Adapter:</strong></p>
  
  <pre><code>public class VideoCardAdapter extends RecyclerView.Adapter&lt;VideoViewHolder&gt; {
  
  private static final String TAG = "VidWall.VideoCardAdapter";
  private List&lt;VideoInfo&gt; videoList;
  private Context activityContext;
  
  public VideoCardAdapter(Context activityContext, List&lt;VideoInfo&gt; videoList) {
      this.activityContext = activityContext;
      this.videoList = videoList;
  }
  
  @Override
  public int getItemCount() {
      return videoList.size();
  }
  
  @Override
  public void onBindViewHolder(final VideoViewHolder videoViewHolder, int i) {
      final VideoInfo videoInfo = videoList.get(i);
      videoViewHolder.textViewTitle.setText(videoInfo.displayName);
      videoViewHolder.imageViewThumbNail.setImageDrawable(ContextCompat.getDrawable(activityContext, activityContext.getResources().getIdentifier(videoInfo.fileNameThumbnail, "drawable", activityContext.getPackageName())));
      videoViewHolder.buttonPreview.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Utils.logDebug(TAG, "buttonPreview clicked");
  
              // Add the YouTube fragment to view
              final YouTubePlayerFragment youTubePlayerFragment = YouTubePlayerFragment.newInstance();
              ((Activity) activityContext).getFragmentManager().beginTransaction().replace(videoViewHolder.containerYouTubePlayer.getId(), youTubePlayerFragment).commit();
              youTubePlayerFragment.initialize(WallpapersActivity.Y_KEY, new YouTubePlayer.OnInitializedListener() {
                  @Override
                  public void onInitializationSuccess(YouTubePlayer.Provider provider, final YouTubePlayer youTubePlayer, boolean b) {
                      Utils.logDebug(TAG, "onInitializationSuccess");
  
                      youTubePlayer.cueVideo("xxxxxxxx");
                      youTubePlayer.setShowFullscreenButton(false);
                  }
  
                  @Override
                  public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
                      Utils.logError(TAG, "Could not initialize YouTubePlayer");
                  }
              });
  
              videoViewHolder.containerYouTubePlayer.setVisibility(View.VISIBLE);
          }
      });
  
  }
  
  @Override
  public VideoViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
  
      View itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.layout_wallpaper_card, viewGroup, false);
  
      return new VideoViewHolder(activityContext, itemView);
  }
  
  }
  </code></pre>