I'm making an app that receive datas from a webservice with an android app that have 2 views.
The first ask the login and the password. Then the activity request to the webservice, and if there is datas, he create an intent that shows the datas in a listview:
Main
private ArrayList accountlist = new ArrayList();
...
accountlist.add(...)
...
Intent intent = new Intent(Main.this, Second.class);
intent.putExtra("accountlist", accountlist);
intent.putExtra("login", loginEditText.getText().toString());
intent.putExtra("pass", passwordEditText.getText().toString());
startActivity(intent);
Second
private ArrayList accountlist;
...
public void onCreate(Bundle savedInstanceState) {
...
setListAdapter(new ArrayAdapter<String>(this, R.layout.results,accountlist));
...
}
private void refresh() {
...
accountlist.add(...)
setListAdapter(new ArrayAdapter<String>(this, R.layout.results,accountlist));
}
The result is that I have the items that are addes into the current list (e.g I have 2 items, if I refresh 4 times, I will have 10 items in the view and I wand only the 2 last)
If you have an idea :D