title: In recyclerview, how do I get each event to open new activities?
body: <p>I am new at coding and have been using a combination of headfirst java and youtube tutorials to create my first app.  I am stuck on trying to get each event to open on their own activities.  At this point, they open up the same activity.  I implemented onclicklistener and adapter. I have been racking my brains as to what I a missing. </p>
  
  <p>Main Activity:</p>
  
  <pre><code>
      package com.example.communityproject12;
  
      import androidx.annotation.NonNull;
      import androidx.appcompat.app.AppCompatActivity;
  
      import android.app.Activity;
      import android.content.Context;
      import android.content.DialogInterface;
      import android.content.Intent;
      import android.os.Bundle;
      import android.os.Handler;
      import android.service.autofill.OnClickAction;
      import android.util.Log;
      import android.view.Gravity;
      import android.view.View;
      import android.view.ViewGroup;
      import android.view.ViewParent;
      import android.view.animation.AccelerateInterpolator;
      import android.widget.Button;
      import android.widget.ImageButton;
      import android.widget.LinearLayout;
      import android.widget.TextView;
      import android.widget.Toast;
  
      import androidx.recyclerview.widget.LinearLayoutManager;
      import androidx.recyclerview.widget.LinearSnapHelper;
      import androidx.recyclerview.widget.RecyclerView;
      import androidx.recyclerview.widget.SnapHelper;
  
      import com.github.rubensousa.gravitysnaphelper.GravitySnapHelper;
  
      import java.util.ArrayList;
      import java.util.EventListener;
      import java.util.List;
  
  
      public class MainActivity extends AppCompatActivity implements EventAdapter.EventListener {
  
  
          RecyclerView eventsplace;
          EventAdapter eventAdapter;
          List&lt;Event&gt; eventList;
  
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
  
  
  
  
              eventsplace = findViewById(R.id.eventsplace);
              eventList = new ArrayList&lt;&gt;();
              eventList.add(
  
                      new Event(
  
                              "AA Meetings",
                              "Support Group",
                               R.drawable.hands
  
                      )
              );
  
              eventList.add(
                      new Event(
                              "Yuma Community Suicide Prevention",
                              "Support",
                              R.drawable.teaching
  
                      )
              );
  
              eventList.add(
                      new Event(
                              "Crisis Resources",
                              "Supports",
                              R.drawable.lonetree
  
  
                      )
              );
  
  
              eventList.add(
                      new Event(
                              "CODA Meetings",
                              "Support Group",
  
                              R.drawable.shoes
                      )
              );
              eventList.add(
                      new Event(
                              "NA Meetings",
                              "Support Group",
                              R.drawable.bamboo
                      )
              );
  
              eventList.add(
                      new Event(
                              "Veteran Resources",
                              "Support",
                              R.drawable.flag
                      )
              );
  
  
  
              eventList.add(
                      new Event(
                              "AzCH Community Forum",
                              "Event",
                              R.drawable.picnic
                      )
              );
  
              eventList.add(
                      new Event(
                              "Al-Anon Meetings",
                              "Support Group",
                              R.drawable.breathe
                      )
              );
  
              eventList.add(
                      new Event(
                              "Depression/Bipolar Alliance",
                              "Support Group",
                              R.drawable.sunrise
                      )
              );
  
  
              final LinearLayoutManager linearLayoutManager = new LinearLayoutManager
                      (this, LinearLayoutManager.HORIZONTAL, false);
  
              eventsplace.setLayoutManager(linearLayoutManager);
              eventsplace.setHasFixedSize(true);
  
              eventAdapter = new EventAdapter(this, eventList, this);
              eventsplace.setAdapter(eventAdapter);
  
  
              // snapping the scroll items
              final SnapHelper snapHelper = new GravitySnapHelper(Gravity.START);
              snapHelper.attachToRecyclerView(eventsplace);
  
  
              // set a timer for default item
              final Handler handler = new Handler();
              handler.postDelayed(new Runnable() {
                  @Override
                  public void run() {
                      // Do something after 1ms = 100ms
                      RecyclerView.ViewHolder viewHolderDefault = eventsplace.
                              findViewHolderForAdapterPosition(0);
  
                      LinearLayout eventparentDefault = viewHolderDefault.itemView.
                              findViewById(R.id.eventparent);
                      eventparentDefault.animate().scaleY(1).scaleX(1).setDuration(350).
                              setInterpolator(new AccelerateInterpolator()).start();
  
                      LinearLayout eventcategoryDefault = viewHolderDefault.itemView.
                              findViewById(R.id.eventbadge);
                      eventcategoryDefault.animate().alpha(1).setDuration(300).start();
  
  
                  }
              }, 100);
  
  
              // add animate scroll
              eventsplace.addOnScrollListener(new RecyclerView.OnScrollListener() {
                  @Override
                  public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
                      super.onScrollStateChanged(recyclerView, newState);
  
                      if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                          View view = snapHelper.findSnapView(linearLayoutManager);
                          int pos = linearLayoutManager.getPosition(view);
  
                          RecyclerView.ViewHolder viewHolder =
                                  eventsplace.findViewHolderForAdapterPosition(pos);
  
                          LinearLayout eventparent = viewHolder.itemView.findViewById(R.id.eventparent);
                          eventparent.animate().scaleY(1).scaleX(1).setDuration(350).
                                  setInterpolator(new AccelerateInterpolator()).start();
  
                          LinearLayout eventcategory = viewHolder.itemView.
                                  findViewById(R.id.eventbadge);
                          eventcategory.animate().alpha(1).setDuration(300).start();
  
                      } else {
  
                          View view = snapHelper.findSnapView(linearLayoutManager);
                          int pos = linearLayoutManager.getPosition(view);
  
                          RecyclerView.ViewHolder viewHolder =
                                  eventsplace.findViewHolderForAdapterPosition(pos);
  
                          LinearLayout eventparent = viewHolder.itemView.findViewById(R.id.eventparent);
                          eventparent.animate().scaleY(0.7f).scaleX(0.7f).
                                  setInterpolator(new AccelerateInterpolator()).setDuration(350).start();
  
                          LinearLayout eventcategory = viewHolder.itemView.
                                  findViewById(R.id.eventbadge);
                          eventcategory.animate().alpha(0).setDuration(300).start();
  
  
                      }
  
              }
  
  
              @Override
              public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                  super.onScrolled(recyclerView, dx, dy);
              }
          });
  
  
      }
  
      @Override
      public void EventClick(int position) {
          eventList.get(position);
          Intent intent = new Intent(this, na.class);
          startActivity(intent);
  
  
      }
  
      public void SecondActivity(View view) {
      }
  </code></pre>
  
  <p>Adapter:</p>
  
  <pre><code>package com.example.communityproject12;
  
  import android.content.Context;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Button;
  import android.widget.ImageView;
  import android.widget.TextView;
  
  import androidx.annotation.NonNull;
  import androidx.recyclerview.widget.RecyclerView;
  
  import java.util.List;
  
  public class EventAdapter extends RecyclerView.Adapter&lt;EventAdapter.EventViewHolder&gt;{
  
      Context context;
      List&lt;Event&gt; eventList;
      EventListener mEventListener;
  
  
  
      public EventAdapter(Context context, List&lt;Event&gt; eventList, EventListener eventListener){
          this.context = context;
          this.eventList = eventList;
          this.mEventListener = eventListener;
      }
  
      @NonNull
      @Override
      public EventViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
          LayoutInflater layoutInflater = LayoutInflater.from(context);
          View view = layoutInflater.inflate(R.layout.item_event, null);
          return new EventViewHolder(view, mEventListener);
      }
  
  
      @Override
      public void onBindViewHolder(@NonNull EventViewHolder eventViewHolder, int i) {
  
          Event event = eventList.get(i);
  
  
          eventViewHolder.eventtitle.setText(event.getEventtitle());
          eventViewHolder.eventcategory.setText(event.getEventcategory());
          eventViewHolder.eventpicture.setImageDrawable(context.getResources().
                  getDrawable(event.getEventpicture()));
  
  
      }
  
      @Override
      public int getItemCount() {
          return eventList.size();
      }
  
      class EventViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
  
         TextView eventtitle, eventcategory;
         ImageView eventpicture;
         EventListener eventListener;
  
          public EventViewHolder(@NonNull View itemView, EventListener eventListener ) {
              super(itemView);
  
              eventtitle = itemView.findViewById(R.id.eventtitle);
              eventcategory = itemView.findViewById(R.id.eventcategory);
              eventpicture = itemView.findViewById(R.id.eventpicture);
  
              this.eventListener = eventListener;
  
              itemView.setOnClickListener(this);
  
          }
  
          @Override
          public void onClick(View v) {
              eventListener.EventClick(getAdapterPosition());
  
          }
      }
  
      public interface EventListener{
          void EventClick(int position);
      }
  
  }
  </code></pre>
  
  <p>Event:</p>
  
  <pre><code>package com.example.communityproject12;
  
  import android.content.Intent;
  import android.service.autofill.OnClickAction;
  import android.view.View;
  
  import androidx.core.content.ContextCompat;
  
  import java.util.BitSet;
  
  import static androidx.core.content.ContextCompat.startActivity;
  
  public class Event {
  
      String eventtitle;
      String eventcategory;
      Integer eventpicture;
  
      public Event() {
      }
  
      public Event(String eventtitle, String eventcategory, Integer eventpicture) {
          this.eventtitle = eventtitle;
          this.eventcategory = eventcategory;
          this.eventpicture = eventpicture;
  
              }
  
      public String getEventtitle() {
          return eventtitle;
      }
  
      public void setEventtitle(String eventtitle) {
          this.eventtitle = eventtitle;
      }
  
      public String getEventcategory() {
          return eventcategory;
      }
  
      public void setEventcategory(String eventcategory) {
          this.eventcategory = eventcategory;
      }
  
      public Integer getEventpicture() {
          return eventpicture;
      }
  
      public void setEventpicture(Integer eventpicture) {
          this.eventpicture = eventpicture;
      }
  
  
  }
  </code></pre>