title: OnClickListener RecyclerView List of buttons
body: <p>I have a RecyclerView and each item is a button. Each button will call the same activity by passing a different parameter to this activity.</p>
  
  <p>I tried many solutions found on the web but none of them had worked for me.</p>
  
  <p>Here is my adapter :</p>
  
  <pre><code>import android.content.Context;
  import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Button;
  import android.widget.LinearLayout;
  
  import java.util.List;
  
  public class FormAdapter extends RecyclerView.Adapter&lt;FormAdapter.FormViewHolder&gt; {
  
      private List&lt;Form&gt; forms;
      private int rowLayout;
      private Context context;
  
  
      public class FormViewHolder extends RecyclerView.ViewHolder {
  
          LinearLayout formsLayout;
          Button form;
  
          public FormViewHolder(View v) {
              super(v);
  
              formsLayout = (LinearLayout) v.findViewById(R.id.forms_layout);
              form = (Button) v.findViewById(R.id.formButton);
  
          }
  
      }
  
      public FormAdapter(List&lt;Form&gt; forms, int rowLayout, Context context) {
          this.forms = forms;
          this.rowLayout = rowLayout;
          this.context = context;
      }
  
  
  
      @Override
      public FormAdapter.FormViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View view = LayoutInflater.from(parent.getContext()).inflate(rowLayout, parent, false);
          return new FormViewHolder(view);
      }
  
  
      @Override
      public void onBindViewHolder(FormViewHolder holder, final int position) {
          holder.form.setText(forms.get(position).getSubject());
      }
  
      @Override
      public int getItemCount() {
          return forms.size();
      }
  
  }
  </code></pre>
  
  <p>A form is represented by the following class :</p>
  
  <pre><code>public class Form {
  
      private final String subject;
      private final int idForm;
  
      public Form(String subject,int idForm)
      {
          this.idForm=idForm;
          this.subject=subject;
      }
  
      public String getSubject()
      {
          return subject;
      }
  
      public int getIdForm()
      {
          return idForm;
      }
  
  }
  </code></pre>
  
  <p>And here is my MainActivity :</p>
  
  <pre><code>import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.util.Log;
  
  import java.util.List;
  import retrofit2.Call;
  import retrofit2.Callback;
  import retrofit2.Response;
  
  public class MainActivity extends AppCompatActivity {
      private static final String TAG = MainActivity.class.getSimpleName();
  
      private final static int idCreator = 1;
      private FormAdapter formAdapter;
      private List&lt;Form&gt; forms;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          setTitle("Main activity");
  
          final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerViewForm);
  
          recyclerView.setLayoutManager(new LinearLayoutManager(this));
  
          Formable formService =
                  ApiClient.getClient().create(Formable.class);
  
          Call&lt;List&lt;Form&gt;&gt; call = formService.getForms(idCreator);
          call.enqueue(new Callback&lt;List&lt;Form&gt;&gt;() {
              @Override
              public void onResponse(Call&lt;List&lt;Form&gt;&gt; call, Response&lt;List&lt;Form&gt;&gt; response) {
                  forms = response.body();
                  formAdapter=new FormAdapter(forms, R.layout.one_form, getApplicationContext());
                  recyclerView.setAdapter(formAdapter);
              }
  
              @Override
              public void onFailure(Call&lt;List&lt;Form&gt;&gt; call, Throwable t) {
                  // Log error here since request failed
                  Log.e(TAG, t.toString());
              }
          });
  
      }
  }
  </code></pre>
  
  <p>I have my buttons on screen but I don't understand how to make them call the activity "QuestionsActivity" with a parameter "idForm" that I know.</p>
  
  <p>Here is the MainActivity when I run the app</p>
  
  <p><a href="https://i.stack.imgur.com/LiKt5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LiKt5.png" alt="enter image description here"></a></p>
  
  <p>Thanks in advance for your help</p>