title: Android/Java: Check if arraylist is empty and then launch another activity
body: <p>Im trying to build this Quiz program where a person is asked a question from and then has to answer, it's a game for two persons, and they just go through all the questions and the game ends.</p>
  
  <p>What i've managed to make so far is the general code for loading the array (the array in the strings.xml file) into an arraylist and then take a random id from 0 to arraylist.size and then show that string (Questions) then it deletes the random id and takes a new one.</p>
  
  <p>But when ive run through all the id's in the arraylist the program crashes, my code looks like this: <a href="http://pastebin.com/MaEj49BL" rel="nofollow">http://pastebin.com/MaEj49BL</a> </p>
  
  <p>The important part is this:</p>
  
  <pre><code>public void gameCode()
  {
      setContentView(R.layout.game);
      if (mList == null) 
  {
       String[] mQuestions = getResources().getStringArray(R.array.mQuestions);
       mList = new ArrayList();
       Collections.addAll(mList, mQuestions);
  }
       else if (mList.isEmpty()) 
  {
       m = (TextView)findViewById(R.id.textView1);
           m.setText("You've run out of questions!");
  }
  if (wList == null) 
  {
     String[] wQuestions = getResources().getStringArray(R.array.wQuestions);
     wList = new ArrayList();
     Collections.addAll(wList, wQuestions);
  } 
  else if (wList.isEmpty()) 
  {
      w = (TextView)findViewById(R.id.textView1);
              w.setText("You've run out of questions!");
  }
  
      //Takes a random ID from the arraylist
      int rndm = generator.nextInt(mList.size());
      int rndw = generator.nextInt(wList.size());
  
  
      //Sets the Strings to a random number from one of the array lists
      String qMan = (String) mList.get(rndm);
      String qWoman = (String) wList.get(rndw);
      if(i == 0)
          {
              //Defines that w is textView1 with the value of qWoman
              w = (TextView)findViewById(R.id.textView1);
              w.setText(qWoman);
              wList.remove(rndw);
              i = 1;
              final Button buttonNext = (Button) findViewById(R.id.buttonNext);
              buttonNext.setOnClickListener(new View.OnClickListener() 
              {
                  public void onClick(View v) 
                  {
                      gameCode();
                  }
              });
          }
      else
          {
  
              m = (TextView)findViewById(R.id.textView1);
              m.setText(qMan);
              mList.remove(rndm);
              i = 0;
              final Button buttonNext = (Button) findViewById(R.id.buttonNext);
              buttonNext.setOnClickListener(new View.OnClickListener() 
              {
                  public void onClick(View v) 
                  {
                      gameCode();
                  }
              });
         }
  
  }  
  </code></pre>
  
  <p>}</p>
  
  <p>There is comments in the source code from the pastebin. Right now I just need to to change the text to "You've run out of questions"</p>