title: How to load youtuble view in RecyclerAdapter in android?
body: <p>I am building an android application where I am trying to load video on RecyclerAdapter. </p>
  
  <p>What I done:</p>
  
  <p>I used youtuble API for loading Thumbnail and video. I am able to load Thumbnail and if I click That Thumbnail the video is played on next page in full screen.</p>
  
  <p>What I need:</p>
  
  <p>I mainly need to play that video there only rather going to next screen.</p>
  
  <p>Below is the RecyclerAdapter class code</p>
  
  <pre><code>package com.recycler.youtube;
  
  /**
  * Created by admin-pc on 05-04-2016.
  */
  public class RecyclerAdapter extends RecyclerView.Adapter&lt;RecyclerAdapter.VideoInfoHolder&gt; {
  
  //these ids are the unique id for each video
  String[] VideoID = {"P3mAtvs5Elc", "nCgQDjiotG0", "P3mAtvs5Elc"};
  Context ctx;
  public  static  String key="AIzaSyD2XJ_kIpxiwIMxY_wlrjGXBl0AAG1DfjA";
  
  public RecyclerAdapter(Context context) {
      this.ctx = context;
  }
  
  @Override
  public VideoInfoHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.video_item, parent, false);
      return new VideoInfoHolder(itemView);
  }
  
  @Override
  public void onBindViewHolder(final VideoInfoHolder holder, final int position) {
  
  
      final YouTubeThumbnailLoader.OnThumbnailLoadedListener  onThumbnailLoadedListener = new YouTubeThumbnailLoader.OnThumbnailLoadedListener(){
          @Override
          public void onThumbnailError(YouTubeThumbnailView youTubeThumbnailView, YouTubeThumbnailLoader.ErrorReason errorReason) {
  
          }
  
          @Override
          public void onThumbnailLoaded(YouTubeThumbnailView youTubeThumbnailView, String s) {
              youTubeThumbnailView.setVisibility(View.VISIBLE);
              holder.relativeLayoutOverYouTubeThumbnailView.setVisibility(View.VISIBLE);
          }
      };
  
      holder.youTubeThumbnailView.initialize(key, new YouTubeThumbnailView.OnInitializedListener() {
          @Override
          public void onInitializationSuccess(YouTubeThumbnailView youTubeThumbnailView, YouTubeThumbnailLoader youTubeThumbnailLoader) {
              youTubeThumbnailLoader.setVideo(VideoID[position]);
              youTubeThumbnailLoader.setOnThumbnailLoadedListener(onThumbnailLoadedListener);
          }
  
          @Override
          public void onInitializationFailure(YouTubeThumbnailView youTubeThumbnailView, YouTubeInitializationResult youTubeInitializationResult) {
              //write something for failure
          }
      });
  }
  
  @Override
  public int getItemCount() {
      return VideoID.length;
  }
  
  public class VideoInfoHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
  
      protected RelativeLayout relativeLayoutOverYouTubeThumbnailView;
      YouTubeThumbnailView youTubeThumbnailView;
      protected ImageView playButton;
  
      public VideoInfoHolder(View itemView) {
          super(itemView);
          playButton=(ImageView)itemView.findViewById(R.id.btnYoutube_player);
          playButton.setOnClickListener(this);
          relativeLayoutOverYouTubeThumbnailView = (RelativeLayout) itemView.findViewById(R.id.relativeLayout_over_youtube_thumbnail);
          youTubeThumbnailView = (YouTubeThumbnailView) itemView.findViewById(R.id.youtube_thumbnail);
      }
  
      @Override
      public void onClick(View v) {
          Intent intent = YouTubeStandalonePlayer.createVideoIntent((Activity) ctx, key, VideoID[getLayoutPosition()]);
          ctx.startActivity(intent);
          // Initializing video player with developer key
       //            youTubeView.initialize(key, this);
      }
   }
  
   }
  </code></pre>
  
  <p>I follow this <a href="https://androidtutorialmagic.wordpress.com/my-mini-project/multiple-youtube-video-in-recyclerviewlistview-in-android/" rel="nofollow">Link</a> to implement the youtube api.</p>