title: Android how to connect two activity if the button onclick with conditions if
body: <p>all</p>
  
  <p>I have difficulty in linking the two activities by using two buttons. The first button serves to select the item in the array. The second function button to proceed to the next page if the text appears on the first button "string 1"</p>
  
  <p>What should I add in my code</p>
  
  <p>This code in array.xml for button3</p>
  
  <pre><code>&lt;string-array name="myArray"&gt; 
  &lt;item&gt;string 1&lt;/item&gt; 
  &lt;item&gt;string 2&lt;/item&gt; 
  &lt;item&gt;string 3&lt;/item&gt; 
  &lt;item&gt;string 4&lt;/item&gt; 
  &lt;item&gt;string 5&lt;/item&gt;
  </code></pre>
  
  <p>This code in beta.java</p>
  
  <pre><code>private String[] myString; 
  private static final Random rgenerator = new Random();
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.next);
      Resources res = getResources();
  
      myString = res.getStringArray(R.array.myArray); 
  
  
  
      Button btn2;
      btn2 = (Button)findViewById(R.id.button3);
      btn2.setOnClickListener(new View.OnClickListener() {
  
          public void onClick(View v) {
  
              final String q = myString[rgenerator.nextInt(myString.length)];
  
              ((Button) v).setText(q);
  
  
  
          }
  
      });
  
      Button btn3;
      btn3 = (Button)findViewById(R.id.button4);
      btn3.setOnClickListener(new View.OnClickListener() {
  
          public void onClick(View arg0) {
              // TODO Auto-generated method stub
  
          }
      });
  </code></pre>
  
  <p>}
  }</p>
  
  <p>What should I add in button4 to be able to go to the next page if the text in the button3 perform "String 1"</p>