title: How to put if statement inside button's OnClickListener in Android
body: <p>I am working on my major project and I want my button to open different intents based on the string array value obtained. I used if and else if statements inside the OnClickListener of the button but it won't click anymore. Please help me.</p>
  
  <p>This is my XML file:</p>
  
  <pre><code>&lt;android.support.v7.widget.CardView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_margin="5dp"
      app:cardCornerRadius="3dp"
      app:cardElevation="2dp"&gt;
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:padding="@dimen/spacing_large"&gt;
      &lt;TextView
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:paddingBottom="@dimen/spacing_middle"
          android:text="Syllabus"
          android:textAppearance="@style/TextAppearance.AppCompat.Title" /&gt;
  
      &lt;Button
          android:id="@+id/buttonpdf"
          style="@style/Widget.AppCompat.Button"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="@color/colorPrimary"
          android:text="Open Book" /&gt;
  
  &lt;/LinearLayout&gt; 
  </code></pre>
  
  <p>And this is the Java file for the same activity:</p>
  
  <pre><code>public class ActivityBookDetails extends AppCompatActivity {
  
      public static final String EXTRA_OBJCT = "com.app.sample.recipe.OBJ";
  
      private Book book;
      private FloatingActionButton fab;
      private View parent_view;
  
      Button button;
      String[] obj;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(activity_book_details);
          parent_view = findViewById(android.R.id.content);
          button = (Button)findViewById(R.id.buttonpdf);
  
  
          book = (Book) getIntent().getSerializableExtra(EXTRA_OBJCT);
          fab = (FloatingActionButton) findViewById(R.id.fab);
          fabToggle();
          setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
          getSupportActionBar().setTitle(book.getName());
  
          ((ImageView) findViewById(R.id.image)).setImageResource(book.getPhoto());
  
          LinearLayout subjects = (LinearLayout) findViewById(R.id.subjects);
  
  
          final String[] title_subjects = getResources().getStringArray(R.array.Subjects);
          addIngredientsList(subjects, title_subjects);
          obj = title_subjects;
  
          button.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  if ("Soft Computing".equals(obj)) {
                      Intent intent = new Intent(ActivityBookDetails.this, pdfviewactivity.class);
  
                      startActivity(intent);
                  }
                  else if ("Web Engineering".equals(obj)) {
                      Intent intent = new Intent(ActivityBookDetails.this, pdfweben.class);
  
                      startActivity(intent);
                  }
                  else if ("Network Management".equals(obj)) {
                      Intent intent = new Intent(ActivityBookDetails.this, pdfnetwork.class);
  
                      startActivity(intent);
                  }
                  else if ("Wireless Network".equals(obj)) {
                      Intent intent = new Intent(ActivityBookDetails.this, pdfwireless.class);
  
                      startActivity(intent);
                  }
              }
          });
  </code></pre>
  
  <p>I want my if else condition to work on the basis of the value of string array.</p>
  
  <p>This is a sample Java file of one of the given intents:</p>
  
  <pre><code>public class pdfwireless extends AppCompatActivity {
      PDFView pdfView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_pdfwireless);
          pdfView = (PDFView)findViewById(R.id.pdfView);
          pdfView.fromAsset("wirelessnetwork.pdf").load();
      }
  }
  </code></pre>