title: Horizontal Recycler View with Videos and Text
body: <p>I have a Horizontal Recycler View with a Thumbnail Image and a Text. On Clicking of Thumbnail image, the respective video should be played. I'm able to show the image and text and now I got stucked with further proceeding  with playing videos.Any help would be much appreciated.</p>
  
  <p><strong>Main Activity</strong></p>
  
  <pre><code> public class MainActivity extends AppCompatActivity {
  
  private RecyclerView horizontal_recycler_view;
  private ArrayList&lt;String&gt; horizontalList;
  private HorizontalAdapter horizontalAdapter;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      horizontal_recycler_view = (RecyclerView) findViewById(R.id.horizontal_recycler_view);
  
      horizontalList = new ArrayList&lt;&gt;();
      horizontalList.add("horizontal 1");
      horizontalList.add("horizontal 2");
      horizontalList.add("horizontal 3");
      horizontalList.add("horizontal 4");
      horizontalList.add("horizontal 5");
  
      horizontalAdapter = new HorizontalAdapter(this, horizontalList);
  
  
      LinearLayoutManager horizontalLayoutManager
              = new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false);
      horizontal_recycler_view.setLayoutManager(horizontalLayoutManager);
  
      horizontal_recycler_view.setAdapter(horizontalAdapter);
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Adapter</strong></p>
  
  <pre><code>    public class HorizontalAdapter extends RecyclerView.Adapter&lt;HorizontalAdapter.MyViewHolder&gt; {
  
  private List&lt;String&gt; horizontalList;
  Context ctxt;
  
  
  public HorizontalAdapter(Context context, List&lt;String&gt; horizontalList) {
      this.ctxt = context;
      this.horizontalList = horizontalList;
  
  }
  
  @Override
  public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View itemView = LayoutInflater.from(parent.getContext())
              .inflate(R.layout.horizontal_item_view, parent, false);
  
      return new MyViewHolder(itemView);
  }
  
  @Override
  public void onBindViewHolder(final MyViewHolder holder, final int position) {
      holder.txtView.setText(horizontalList.get(position));
  
      holder.imgView.setImageResource(R.drawable.thumbnail);
  
      holder.txtView.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Toast.makeText(ctxt, holder.txtView.getText().toString(), Toast.LENGTH_SHORT).show();
          }
      });
  }
  
  @Override
  public int getItemCount() {
      return horizontalList.size();
  }
  
  public class MyViewHolder extends RecyclerView.ViewHolder {
      public TextView txtView;
      public ImageView imgView;
  
  
      public MyViewHolder(View view) {
          super(view);
          imgView = (ImageView) view.findViewById(R.id.thumbnail);
          txtView = (TextView) view.findViewById(R.id.video_title);
  
      }
  }
  </code></pre>
  
  <p>}</p>