title: Remove an item in RecyclerView- Android
body: <p>I am facing a problem, I could not remove an Item in RecyclerView.
  I am trying to search in Internet, but could not see any solution
  I am following to this post
  <a href="https://stackoverflow.com/questions/26076965/android-recyclerview-addition-removal-of-items">Android RecyclerView addition &amp; removal of items</a>
  But I still could not remove the item selected
  Below is my code for my adapter and fragement</p>
  
  <p>RecyclerViewAdapter.java</p>
  
  <pre><code>public class RecyclerViewAdapter extends RecyclerView.Adapter&lt;RecyclerViewAdapter.ViewHolder&gt; {
  List&lt;VideoDetails&gt; contents2;
  Context mContext;
  ImageLoader imageLoader;
  static final int TYPE_HEADER = 0;
  static final int TYPE_CELL = 1;
  public RecyclerViewAdapter(List&lt;VideoDetails&gt; contents) {
      this.contents2 = contents;
  }
  public RecyclerViewAdapter(Context context, List&lt;VideoDetails&gt; contents) {
      mContext = context;
      this.contents2 = contents;
      imageLoader = new ImageLoader(context);
  }
  @Override
  public int getItemViewType(int position) {
      return position;
  
  }
  @Override
  public int getItemCount() {
      return contents2.size();
  }
  @Override
  public RecyclerViewAdapter.ViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) {
      View view = null;
      view = LayoutInflater.from(parent.getContext())
              .inflate(R.layout.list_item_card_small2, parent, false);
      ViewHolder vh = new ViewHolder(view);
      return vh;
  }
   @Override
  public void onBindViewHolder(ViewHolder holder,final int position) {
      holder.title.setText(contents2.get(position).getTitle());
       holder.image.setOnClickListener(new View.OnClickListener(){
           @Override
           public void onClick(View view) {
               Log.d("thien.van","on Click onBindViewHolder");
               contents2.remove(position);
               notifyItemRemoved(position);
               notifyItemRangeChanged(position, contents2.size());
  
           }
       });
  }
  public Bitmap getThumbnail(String str) {
  
      Bitmap bMap = ThumbnailUtils.createVideoThumbnail(str, MediaStore.Video.Thumbnails.MINI_KIND);
      return bMap;
  }
  public class ViewHolder extends RecyclerView.ViewHolder implements  View.OnClickListener {
  
  
      public TextView title;
      public ImageView image;
      public ProgressBar progressBar;
  
      public ViewHolder(View itemView) {
          super(itemView);
          title = (TextView) itemView.findViewById(R.id.title);
          image = (ImageView) itemView.findViewById(R.id.thumbnail);
          progressBar = (ProgressBar) itemView.findViewById(R.id.progress);
        //  image.setOnClickListener(this);
      }
      @Override
      public void onClick(View view) {
          Log.d("thien.van","onClick getAdapterPosition             () = "+getAdapterPosition());
          removeAt(getAdapterPosition());
      }
  }
  public void removeAt(int position) {
      contents2.remove(position);
      notifyDataSetChanged();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>RecyclerViewFragment</p>
  
  <pre><code>public class RecyclerViewFragment extends Fragment {
  
  private RecyclerView mRecyclerView;
  private RecyclerView.Adapter mAdapter;
  
  private static final int ITEM_COUNT = 2;
  
  private List&lt;Object&gt; mContentItems = new ArrayList&lt;&gt;();
  private static List&lt;VideoDetails&gt; mContentItems2 = new ArrayList&lt;&gt;();
  
  public static RecyclerViewFragment newInstance() {
      return new RecyclerViewFragment();
  }
  
  public static RecyclerViewFragment newInstance(List&lt;VideoDetails&gt; contentItems) {
      RecyclerViewFragment myFragment = new RecyclerViewFragment();
      //  mContentItems = contentItems;
      Bundle args = new Bundle();
      args.putSerializable("thienvan", (Serializable) contentItems);
      myFragment.setArguments(args);
      return myFragment;
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      mContentItems2 = (List&lt;VideoDetails&gt;) getArguments().getSerializable("thienvan");
      // Log.d("thien.van","Fragment file name = "+mContentItems2.get(0).getTitle());
      return inflater.inflate(R.layout.fragment_recyclerview, container, false);
  }
  
  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
      super.onViewCreated(view, savedInstanceState);
      mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
      RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
      mRecyclerView.setLayoutManager(layoutManager);
      //mRecyclerView.setHasFixedSize(true);
  
      mAdapter = new RecyclerViewMaterialAdapter(new RecyclerViewAdapter(getActivity().getBaseContext(),mContentItems2));
      mRecyclerView.setAdapter(mAdapter);
  
      /*{
          for (int i = 0; i &lt; ITEM_COUNT; ++i)
              mContentItems.add(new Object());
          mAdapter.notifyDataSetChanged();
      }*/
  
      MaterialViewPagerHelper.registerRecyclerView(getActivity(), mRecyclerView, null);
  }
  //http://android--code.blogspot.com/2015/12/android-recyclerview-add-remove-item.html
  </code></pre>
  
  <p>}</p>
  
  <p>I could not remove an item inside Adapter class.
  Anybody could help me ?</p>