I have an Activity
where names are inputed via a EditText
box and then they get saved into an Array
and then displayed in a ListView
where there is also a Button
that will appear where they can remove it.
Once the correct names have been added they are then passed to the next Activity
by a Button
Intent
to populate a String
. On the next Activity
there is a button where they can go back to the previous Activity
to add more names or remove.
The problem is when they go back to the previous Activity
the Array
is empty so I need a way to save the Array
even when the Activity
has been left.
ArrayList<String> playerList = new ArrayList<String>();
Button to add to the Array
is below:
Button confirm = (Button) findViewById(R.id.add);
confirm.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
EditText playername = (EditText) findViewById(R.id.userinput);
playerList.add(playername.getText().toString());
adapter.notifyDataSetChanged();
playername.setText("");
}
});