Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2012
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. package com.compliment;
  2.  
  3. import java.util.Random;
  4.  
  5. import com.compliment.R;
  6. import android.app.Activity;
  7. import android.os.Bundle;
  8. import android.view.View;
  9. import android.widget.TextView;
  10.  
  11. public class ComplimentGenerator extends Activity {
  12.     /** Called when the activity is first created. */
  13.     @Override
  14.     public void onCreate(Bundle savedInstanceState) {
  15.         super.onCreate(savedInstanceState);
  16.         setContentView(R.layout.main);
  17.     }
  18.    
  19.     private static final Random RANDOM = new Random();
  20.    
  21.     private static final String[] COMPLIMENTS = {
  22.           "Have A Great Way \n " +
  23.           "      With Words",
  24.           "Are A Terrific " +
  25.           "\n     Leader",
  26.           "Make Working On \n" +
  27.           "      A Project A Joy",
  28.           "Are Very Creative",
  29.           "Are A Good " +
  30.           "\n     Provider",
  31.           "Are Fun To " +
  32.           "\n      Be With",
  33.           "Have A Great " +
  34.           "\n   Reputation",
  35.           "Are Cleaver",
  36.           "Make A House " +
  37.           "\n  Feel Like A Home",
  38.           "Are Kind",
  39.           "Are Intelligent",
  40.           "Are Funny",
  41.           "Are Unique",
  42.           "Warm My Heart",
  43.           "Make Me Smile",
  44.           "Are Very Loving"
  45.          
  46.          
  47.         };
  48.  
  49.     public void generateCompliment(View v) {
  50.         // Select a random hello.
  51.         int complimentLength = COMPLIMENTS.length;
  52.         String compliment = COMPLIMENTS[RANDOM.nextInt(complimentLength)];
  53.         TextView label = (TextView)findViewById(R.id.label);
  54.         label.setText("You " + compliment);
  55.        
  56.        
  57.     }
  58.  
  59.    
  60.    
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement