Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.compliment;
- import java.util.Random;
- import com.compliment.R;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.TextView;
- public class ComplimentGenerator extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- }
- private static final Random RANDOM = new Random();
- private static final String[] COMPLIMENTS = {
- "Have A Great Way \n " +
- " With Words",
- "Are A Terrific " +
- "\n Leader",
- "Make Working On \n" +
- " A Project A Joy",
- "Are Very Creative",
- "Are A Good " +
- "\n Provider",
- "Are Fun To " +
- "\n Be With",
- "Have A Great " +
- "\n Reputation",
- "Are Cleaver",
- "Make A House " +
- "\n Feel Like A Home",
- "Are Kind",
- "Are Intelligent",
- "Are Funny",
- "Are Unique",
- "Warm My Heart",
- "Make Me Smile",
- "Are Very Loving"
- };
- public void generateCompliment(View v) {
- // Select a random hello.
- int complimentLength = COMPLIMENTS.length;
- String compliment = COMPLIMENTS[RANDOM.nextInt(complimentLength)];
- TextView label = (TextView)findViewById(R.id.label);
- label.setText("You " + compliment);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement