Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Practice updating ListView

What I am doing:
The app I'm developing has a clickable list of subjects that is systematically added by the user. At the end of a term/semester, the user clears the list for the next, deleting all the files in which the user values are saved.

The Question:
Is it better practice to simply refresh the activity I am working on by using:

finish();
startActivity(getIntent());

or to clear the list by re-initiating the the ArrayAdapter (named listAdapter) and resetting it using:

listAdapter = new ArrayAdapter<String>(this, R.layout.simplerow, R.id.rowTextView);
testListView.setAdapter(listAdapter);

or is there a better way all together?

like image 799
Onyxa Avatar asked Mar 27 '26 11:03

Onyxa


1 Answers

change the values in array and call adapter.notifyDataSetChanged();

like image 151
Ashish Avatar answered Mar 29 '26 01:03

Ashish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!