Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
クイズを含むアプリケーションを開発しています。次のボタンを押すと、次の質問に切り替わります。ただし、これらの質問をランダムに表示したいと考えています。私はxmlを解析し、質問をそのオプションに表示しました!
arrayすべての質問が、または何らかのデータ構造に保存されていると仮定します。ArrayList
array
ArrayList
アクティビティで 1 つのランダム オブジェクトを 1 回だけ定義する必要があります
例えば
Random random = new Random();
次の質問インデックスを取得します。
int nextQuestionIndex = random.nextInt(n); // where n is the total number of questions