title: passing values from recycler adapter to fragment in android
body: <p>I've a recycler adapter where I've added <code>setOnClickListener</code> for items in adapter. Code is as given below:  </p>
  
  <pre><code>@Override
      public void onBindViewHolder(final FiltersAdapter.MyViewHolder holder, final int position) {
          holder.mOrganizer.setText(filtersList.get(position));
          holder.mLayout.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  try {
                      //Log.e("message","ONclick FIlter");
                      if (holder.mOrganizerCheck.isChecked()){
                          holder.mOrganizerCheck.setChecked(false);
                      }else {
                          holder.mOrganizerCheck.setChecked(true);
                          int pos = holder.getAdapterPosition();
  
                          filtersList.get(pos);
  
                          /*Bundle bundle = new Bundle();
                          bundle.putInt(pos, );*/
  
                          Log.d(TAG, "onClick: " +filtersList);
                          Log.d(TAG, "onClick of position: " +pos);
  
                      }
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
          });  
  </code></pre>
  
  <p>And here is fragment code which deals with getting values from adapter to fragment.  </p>
  
  <pre><code>private void initView() {
          mrvFilterBySender = (RecyclerView) mFilterView.findViewById(R.id.rvFilterBySender);
          mFiltersAdapter = new FiltersAdapter(getActivity(), mListOrganizer);
          RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext());
          mrvFilterBySender.setLayoutManager(mLayoutManager);
  
          mrvFilterBySender.setAdapter(mFiltersAdapter);
          mFiltersAdapter.notifyDataSetChanged();
  
          mrvFilterBySender.setAdapter(mFiltersAdapter);
          mrvFilterBySender.setRecyclerListener(new RecyclerView.RecyclerListener() {
              @Override
              public void onViewRecycled(RecyclerView.ViewHolder holder) {
                  holder.getAdapterPosition();
              }
          });
  
      }  
  </code></pre>
  
  <p>I'm trying to pass <code>pos</code> and value having that <code>pos</code> from adapter to fragment. But my code isn't working. How can I fix it?</p>