Guest User

Untitled

a guest
Jan 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.89 KB | None | 0 0
  1. public void gameCode()
  2.     {
  3.         // Perform action on click
  4.         setContentView(R.layout.game);
  5.        
  6.         //Loads the questions to the arrays
  7.         String[] mQuestions = getResources().getStringArray(R.array.mQuestions);
  8.         String[] wQuestions = getResources().getStringArray(R.array.wQuestions);
  9.            
  10.         //experimental with ArrayList
  11.         ArrayList mList = new ArrayList();
  12.         ArrayList wList = new ArrayList();
  13.         Collections.addAll(mList, mQuestions);
  14.         Collections.addAll(wList, wQuestions);
  15.                
  16.         //Takes a random ID from the array
  17.         Random generator = new Random();
  18.         int rndm = generator.nextInt(mQuestions.length);
  19.         int rndw = generator.nextInt(wQuestions.length);
  20.        
  21.        
  22.         String qMan = mQuestions[rndm];
  23.         String qWoman = wQuestions[rndw];
  24.         if(i == 0)
  25.             {
  26.                
  27.                 w = (TextView)findViewById(R.id.textView1);
  28.                 w.setText(qWoman);
  29.                 mList.remove(rndw);
  30.                 i = 1;
  31.                 final Button buttonNext = (Button) findViewById(R.id.buttonNext);
  32.                 buttonNext.setOnClickListener(new View.OnClickListener()
  33.                 {
  34.                     public void onClick(View v)
  35.                     {
  36.                         gameCode();
  37.                     }
  38.                 });
  39.             }
  40.         else
  41.             {
  42.                
  43.                 m = (TextView)findViewById(R.id.textView1);
  44.                 m.setText(qMan);
  45.                 wList.remove(rndm);
  46.                 i = 0;
  47.                 final Button buttonNext = (Button) findViewById(R.id.buttonNext);
  48.                 buttonNext.setOnClickListener(new View.OnClickListener()
  49.                 {
  50.                     public void onClick(View v)
  51.                     {
  52.                         gameCode();
  53.                     }
  54.                 });
  55.            }
  56.      
  57.     }  
  58.  
  59. }
Add Comment
Please, Sign In to add comment