Note that there are some explanatory texts on larger screens.

plurals
  1. POArray List transfering correctly & Setting a score to each array list member
    primarykey
    data
    text
    <p>To all you that have helped me with my other questions thank you. I almost have it, but 2 final problems are preventing it from working the way i want.</p> <p>These 2 classes are supposed to do as follows. 1st class gets the names of the people that want to play the game. Uses the same EditText and when they input their name they click submit. When all the names are submitted they click the done/play button which sends them and their data (how many players and names) to the next class. On class 1 i believe the error lies in the submit button. I'm trying to add all the names to an array list and I dont believe it is doing it correctly. When I run the app it takes in the names just fine from the users standpoint. But on the following screen it should display their name: (it says null so it is not getting the names correctly) and a task to do (which it does correctly). </p> <p>The last thing it needs to do is on class 2 it needs to allow those buttons (failed, champ, and not bad) to only need to be clicked once (then it sets a score to the name of the person who's turn it was) and then it needs to start the next person and task. (It does neither atm). I would really appreciate help getting this blasted thing to work. Thanks to all who take the time to reply. And sorry if ur sick of seeing my help requests.</p> <p>Class 1</p> <pre><code>public class Class1 extends Activity { int players=0, i=0; String names[]; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.class1); final EditText input = (EditText) findViewById(R.id.nameinput); final ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;(); //names = new String[players]; Button submitButton = (Button) findViewById(R.id.submit_btn); submitButton.setOnClickListener(new View.OnClickListener() { public void onClick(View submit1) { //for( i=i; i &lt; players; i++) //{ players++; names.add(input.getText().toString()); //names[i] = input.getText().toString(); input.setText(""); //} } }); Button doneButton = (Button) findViewById(R.id.done_btn); doneButton.setOnClickListener(new View.OnClickListener() { public void onClick(View done1) { Intent done = new Intent(Class1.this, Game.class); Bundle bundle = new Bundle(); bundle.putStringArrayList("arrayKey", names); done.putExtra("players", players); //done.putExtra("names", names[players]); startActivity(done); } }); } </code></pre> <p>Game Class</p> <pre><code>public class Game extends Activity { int players, counter=0, score, ptasks,rindex; String[] names; String[] tasks; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.game); Bundle bundle = this.getIntent().getExtras(); String[] names = bundle.getStringArray("arrayKey"); Intent game = getIntent(); players = game.getIntExtra("players", 1); //names = game.getStringArrayExtra("names"); Random generator = new Random(); tasks = new String[10]; tasks[0]= ""; tasks[1]= ""; tasks[2]= ""; tasks[3]= ""; tasks[4]= ""; tasks[5]= ""; tasks[6]= ""; tasks[7]= ""; tasks[8]= ""; tasks[9]= ""; names = new String[players]; while (counter &lt;5) { for (int i = 0; i &lt; players; i++) { TextView name1 = (TextView) findViewById(R.id.pname); name1.setText( names[i]+":"); ptasks = 10; rindex = generator.nextInt(ptasks); TextView task = (TextView) findViewById(R.id.task); task.setText( tasks[rindex]); Button failButton = (Button) findViewById(R.id.fail_btn); failButton.setOnClickListener(new View.OnClickListener() { public void onClick(View failed) { return; } }); Button notButton = (Button) findViewById(R.id.notbad_btn); notButton.setOnClickListener(new View.OnClickListener() { public void onClick(View notbad) { return; } }); Button champButton = (Button) findViewById(R.id.champ_btn); champButton.setOnClickListener(new View.OnClickListener() { public void onClick(View champp) { return; } }); } counter++; } } } </code></pre> <p>As a side note. The things that you see within those sections that have // comments next to them I have there because i was testing out between those and the ones that arent commented out and neither worked. If you have any input on fixing any of this i appreciate it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload