Android examples for java.util:Random
random List item
import android.annotation.SuppressLint; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Random; public class Main{ public static List<String> randomList(List<String> options) { int min = 1; int max = options.size(); List<String> list = new ArrayList<String>(options); String temp2 = list.get(max - 1); list.remove(max - 1);// www .j a v a 2 s. c o m list.add(1, temp2); Random r = new Random(); for (int i = 0; i < max; i++) { int rand = r.nextInt(max - min) + min; String temp = list.get(0); list.add(rand, temp); list.remove(0); } return list; } }