title: Open different activity from list view in Android
body: <p>I am using a list view to display from data from firebase. From the <a href="https://i.stack.imgur.com/fGGcM.png" rel="nofollow noreferrer">Listview</a>, when the user clicks on "Test 1" it will open the "Cardio" type page for test 1. And if they click "Test 2" it opens an "Other" type page for test 2.</p>
  
  <p>It does open the cardio and other pages but once the app is code. It doesn't open any of the pages. When you click on the items from the list view it doesn't do anything. And if I save a new workout, that one will work fine.</p>
  
  <p>What do I need to add to make sure it opens the correct pages every time?</p>
  
  <p>This is the code I'm using to open the pages.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>listViewWorkouts.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
               WorkoutDB viewworkout = workoutList.get(i);
  
                  if (viewworkout.getWorkoutCategory() == "Cardio"){
  
                      Intent intent = new Intent(getApplicationContext(), AddCardioActivity.class);
  
                      intent.putExtra(WORKOUT_ID, viewworkout.getWorkoutId());
                      intent.putExtra(WORKOUT_NAME, viewworkout.getWorkoutName());
                      intent.putExtra(WORKOUT_CATEGORY, viewworkout.getWorkoutCategory());
                      intent.putExtra(WORKOUT_DATE, viewworkout.getWorkoutDate());
  
  
                      startActivity(intent);
                  }
                  else if (viewworkout.getWorkoutCategory() == "Other"){
                      Intent intent = new Intent(getApplicationContext(),AddDetailActivity.class);
  
                      intent.putExtra(WORKOUT_ID, viewworkout.getWorkoutId());
                      intent.putExtra(WORKOUT_NAME, viewworkout.getWorkoutName());
                      intent.putExtra(WORKOUT_CATEGORY, viewworkout.getWorkoutCategory());
                      intent.putExtra(WORKOUT_DATE, viewworkout.getWorkoutDate());
  
  
                      startActivity(intent);
                  }
                  
          });</code></pre>
  </div>
  </div>
  </p>