Currently, I'm now on developing dictionary offline application for Android. In this application, I'm using SQLite for storage and Asynctask for background retrieving data. When user input word into search box, progress dialogue box will be displayed as retrieving the definition of input word. At that time, I don't want to display "loading" message in progress box because it's so simple and conservative idea. What I want is I want to display random message of "Quote, motto, joke, etc.." instead of "loading" message.
That's why I've created new class file for random message as follow.
2
3public class RandomMessage {
4 public static String getMessage() {
5 final String rank[]= {
6 "The only true wisdom is in knowing you know nothing.",
7 "A wise man does not need advice and a fool won't take it.",
8 "Artificial Intelligence is no match for Natural Stupidity.",
9 "He who can, does. He who can't, teaches.",
10 "Being cool, is not trying to be cool.",
11 "Wisdom begins in wonder.",
12 "Be of use, but don't be used.",
13 "Winners never quit and quitters never win.",
14 "Why is abbreviation such a long word ?",
15 "Sports do not build character. They reveal it.",
16 "Remember that time is money.",
17 "One thing I can give and still keep: my word."
18 };
19
20 Random randInt = new Random();
21 String b = rank[randInt.nextInt(rank.length)];
22 return b;
23 }
24}
When we need to use Random function, we need to import "import java.util.Random". After that, I need to create string and put all the quotes and jokes into this string. Then, create random object. Then render all of quotes by this object and fetch random message from the string list.
How to call above class? Here is coding

Android
Top of Page