android - How can I efficiently change the underlying list of an ArrayAdapter? -


i have created customarrayadapter extends arrayadapter, , initialized arraylist list1. upon user action, create second list, list2, takes few moments populate. upon successful creation, want customarrayadapter use list2 data source instead.

for example:

list2 = new arraylist<>(); //actions populate list2 list1 = list2; customadapter.notifydatasetchanged(); 

but, of course, customadapter not update because still looks @ memory address list1 used point to, still uses old data.

what best way efficiently change list customadapter using data? example, do:

list1.clear(); list1.addall(list2); 

but horribly inefficient.


Comments