title: Button click to go from one activity to random in a list of activity
body: <p>I want the best way to go from one class on button click to a random activity from a list of activities... please mention where in java i have to place it aswell.. as you can see iam already trying one method but i cant repeat else and for some reason i get an error with rand which java isnt recognising .. thanks in advance guys</p>
  
  <pre><code>    package com.example.whattodo2;
  
      import java.util.Random;
  
      import android.os.Bundle;
      import android.app.Activity;
       import android.content.Intent;
  
      import android.view.Menu;
      import android.view.View;
  
      import android.view.animation.Animation;
      import android.view.animation.AnimationUtils;
      import android.widget.Button;
      import android.widget.ImageView;
  
  
      public class Title extends Activity {
  
  
  
      Button reset, rts;
      ImageView title;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_title);
          Animation a = AnimationUtils.loadAnimation(this, R.animator.animation);
           ImageView rImage = (ImageView) findViewById(R.id.title);
           rImage.startAnimation(a);
           func();
  
          reset = (Button) findViewById(R.id.reset);
          reset.setOnClickListener(new View.OnClickListener() {
  
                      @Override
                      public void onClick(View arg0) {
                          if(rand &lt; 0.5){
                                 Intent reset1 = new Intent(Title.this, MainActivity.class);
                                 startActivity(reset1);
                             } else {
                                 Intent reset2 = new Intent(Title.this, Question36.class);
                                 startActivity(reset2); }
                      }
                  });
          rts = (Button) findViewById(R.id.rts);
          rts.setOnClickListener(new View.OnClickListener() {
  
                      @Override
                      public void onClick(View arg0) {
                          // TODO Auto-generated method stub
                          Intent rts=new Intent(Title.this,Rts.class);
                          startActivity(rts);
  
                      }
                  });
  
  
      }
  
      protected void func() {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.title, menu);
          return true;
      }
  
  
  
  }
  </code></pre>