Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void gameCode()
- {
- // Perform action on click
- setContentView(R.layout.game);
- //Loads the questions to the arrays
- String[] mQuestions = getResources().getStringArray(R.array.mQuestions);
- String[] wQuestions = getResources().getStringArray(R.array.wQuestions);
- //experimental with ArrayList
- ArrayList mList = new ArrayList();
- ArrayList wList = new ArrayList();
- Collections.addAll(mList, mQuestions);
- Collections.addAll(wList, wQuestions);
- //Takes a random ID from the array
- Random generator = new Random();
- int rndm = generator.nextInt(mQuestions.length);
- int rndw = generator.nextInt(wQuestions.length);
- String qMan = mQuestions[rndm];
- String qWoman = wQuestions[rndw];
- if(i == 0)
- {
- w = (TextView)findViewById(R.id.textView1);
- w.setText(qWoman);
- mList.remove(rndw);
- i = 1;
- final Button buttonNext = (Button) findViewById(R.id.buttonNext);
- buttonNext.setOnClickListener(new View.OnClickListener()
- {
- public void onClick(View v)
- {
- gameCode();
- }
- });
- }
- else
- {
- m = (TextView)findViewById(R.id.textView1);
- m.setText(qMan);
- wList.remove(rndm);
- i = 0;
- final Button buttonNext = (Button) findViewById(R.id.buttonNext);
- buttonNext.setOnClickListener(new View.OnClickListener()
- {
- public void onClick(View v)
- {
- gameCode();
- }
- });
- }
- }
- }
Add Comment
Please, Sign In to add comment