Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sexica.foreplay;
- import java.util.Arrays;
- import java.util.Collections;
- import java.util.List;
- import java.util.Random;
- import java.util.ArrayList;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.TextView;
- //import android.content.Intent;
- public class Sexica4PlayActivity extends Activity
- {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- {
- final Button buttonPlay = (Button) findViewById(R.id.buttonPlay);
- buttonPlay.setOnClickListener(new View.OnClickListener()
- {
- public void onClick(View v)
- {
- gameCode();
- }
- });
- }
- }
- int i = 0;
- TextView w;
- TextView m;
- 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