@Override public void run() { final int N = getChildCount(); final int K = 1; // irand(1,3); for (int i = 0; i < K; i++) { final View child = getChildAt((int) (Math.random() * N)); place(child, true); } fillFreeList(); if (mStarted) { mHandler.postDelayed(mJuggle, DELAY); } }
static float frand() { return (float) (Math.random()); }
<T> T pick(SparseArray<T> sa) { return sa.valueAt((int) (Math.random() * sa.size())); }
<T> T pick(T[] a) { return a[(int) (Math.random() * a.length)]; }
int pick(int[] a) { return a[(int) (Math.random() * a.length)]; }