title: How do I write a random quote generator in Java for Android?
body: <p>I am very new to Java for Android, and am basically just a noob trying to make a few basic apps for a HTC phone. So far, mainly by copying code, I've written apps that will write "Hello, World", print a random number and display a picture, and these have worked nicely on my phone. </p>
  
  <p>I would now like to combine what I've done and write an app that will generate a random quote from a specified list and print it on the screen. A refresh button would be nice, too. </p>
  
  <p>I looked at these links first as a starting point: 
  <a href="http://forrst.com/posts/Java_Get_random_quote_from_list_of_quotes-OWt" rel="nofollow noreferrer">Forrst</a>
  <a href="https://stackoverflow.com/questions/2405411/how-to-generate-a-random-number-then-display-it-on-screen">Stack Overflow</a></p>
  
  <p>However, I think I'm going in circles now by trying to combine the two. I started off by making an array of the quotes, generating a random number and assigning it to the quote, then trying to get the tv.setText method to write it. </p>
  
  <p>Any help gratefully received! Thank you!</p>
  
  <p>This is what I have so far: </p>
  
  <pre><code>package com.Me;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.widget.TextView;
  import java.util.Random;
  
  public class QuoteActivity extends Activity {
  
  int numQuotes = 10;
  String[] quotes = new String[numQuotes] {"John", "Mary", "Bob"};
  String randomQuote = quotes[Math.floor(Math.random() * numQuotes)];
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      //Make a new text view passing Activity object
      TextView tv = new TextView(this);
      //Set a text into view
  
      tv.setText(randomQuote);
      //set the view into activity view container
      setContentView(tv);
  }
  </code></pre>
  
  <p>}</p>