title: Android: How to get the Checked items of checkbox in RecyclerView to send it to server
body: <p>I am trying to select the checked items of the <code>checkbox</code> get the positions of item checked so as to send it to the server.</p>
  
  <p>My adapter is:</p>
  
  <pre><code>public class FollowTopicsAdapter extends RecyclerView.Adapter&lt;FollowTopicsAdapter.MyViewHolder&gt;  {
  
      ArrayList&lt;String&gt; topics_title, topics_id;
      ArrayList&lt;String&gt; checked_items= new ArrayList&lt;&gt;();
      Context context;
      LinearLayout linearLayout;
      CheckBox checkBox;
  
      public FollowTopicsAdapter(Context context, ArrayList&lt;String&gt; topics_title, ArrayList&lt;String&gt; topics_id){
          this.topics_title=topics_title;
          this.context=context;
          this.topics_id=topics_id;
      }
  
      @Override
      public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_for_follow_topics,parent,false);
  
          return new MyViewHolder(view);
      }
  
      @Override
      public void onBindViewHolder(final MyViewHolder holder, final int position) {
          holder.checkBox.setText(topics_title.get(position));
          holder.checkBox.setTag(topics_title.get(position));
  
          holder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                  if(b)
                  {
                      checked_items.add(position,topics_id.get(position));
                      holder.checkBox.setChecked(b);
                      linearLayout.setBackgroundResource(R.drawable.checked);
                  }
                  else
                  {
                      checked_items.remove(position);
                      holder.checkBox.setChecked(b);
                      linearLayout.setBackgroundResource(R.drawable.custom_checkbox);
                  }
  
              }
          });
      }
  
  
      @Override
      public int getItemCount() {
          return topics_title.size();
      }
  
      public class MyViewHolder extends RecyclerView.ViewHolder {
          CheckBox checkBox;
  
          public MyViewHolder(View view) {
              super(view);
              linearLayout=(LinearLayout)itemView.findViewById(R.id.linearLayout);
              checkBox= (CheckBox)itemView.findViewById(R.id.checkbox);
          }
      }
  }
  </code></pre>