Note that there are some explanatory texts on larger screens.

plurals
  1. POArrayList stores only two values
    primarykey
    data
    text
    <pre><code>public class ClientGame extends Activity implements OnClickListener{ Button Answer1, Answer2, Answer3, Answer4; TextView txtQuest; DatabaseHelper dbHelper; Cursor cur; String qid; String[] _ids = {}; ArrayList&lt;String&gt; idList; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.clientgame); dbHelper = new DatabaseHelper(this); cur = dbHelper.getRandomQuestion(); startManagingCursor(cur); qid = cur.getString(cur.getColumnIndex(DatabaseHelper.colID)); idList = new ArrayList&lt;String&gt;(); idList.add(qid); // i take the current id try { Intent extras = getIntent(); String ID = extras.getStringExtra("_id"); idList.add(ID); // add the previous one _ids = (String[]) idList.toArray(new String[0]); score = (TextView)findViewById(R.id.textView2); score.setText("Your score is " + idList); } catch(Exception e) { } Answer1 = (Button) findViewById(R.id.button1); Answer1.setText(answer1); Answer1.setOnClickListener(this); Answer2 = (Button) findViewById(R.id.button2); Answer2.setText(answer2); Answer2.setOnClickListener(this); Answer3 = (Button) findViewById(R.id.button3); Answer3.setText(answer3); Answer3.setOnClickListener(this); Answer4 = (Button) findViewById(R.id.button4); Answer4.setText(answer4); Answer4.setOnClickListener(this); } @Override public void onPause() { super.onPause(); finish(); } @Override public void onClick(View view) { //correct answer check and store skore and id if (view == findViewById(R.id.button1)) { int i = 1; String ID = cur.getString(cur.getColumnIndex("_id")); Intent ini = new Intent(ClientGame.this, ClientGame.class); ini.putExtra("_id", ID); startActivity(ini); } if (view == findViewById(R.id.button2)) { int i = 1; String ID = cur.getString(cur.getColumnIndex("_id")); Intent ini = new Intent(ClientGame.this, ClientGame.class); ini.putExtra("_id", ID); startActivity(ini); } if (view == findViewById(R.id.button3)) { int i = 1; String ID = cur.getString(cur.getColumnIndex("_id")); Intent ini = new Intent(ClientGame.this, ClientGame.class); ini.putExtra("_id", ID); startActivity(ini); } if (view == findViewById(R.id.button4)) { int i = 1; String ID = cur.getString(cur.getColumnIndex("_id")); Intent ini = new Intent(ClientGame.this, ClientGame.class); ini.putExtra("_id", ID); startActivity(ini); } } </code></pre> <p>} The problem here is that on the textview is displayed only two ids. The last one and the current. I want to show all the ids as far as the user wants. Not infinite of course. So how can i create an arraylist, lets say with ten values, and store the id each time?</p>
    singulars
    1. This table or related slice is empty.
    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