views:

353

answers:

1

This is continuation to the question I already asked a while back. I've been offered a solution which is not really working. Anyway - here's the problem/question

I look at some posts from the past and it seems that if I add items to the ListView adapter it should update itself and user should be able to scroll to the newly appended items. Unfortunately it's not what I observe. If I append new items to my existing ArrayAdapter I only will see updated results if I rerun ListView#setAdapter again. Doing nothing, invalidating view etc. doesn't do anything. Here's a snippet:

SearchItemsAdapter a = (SearchItemsAdapter) listview.getAdapter();
List<SearchItem> values = fetchNextSetOfItems();
a.append(values);
// unless I do this - I will not see the update, but if I do - 
// I'll jump to the top
listview.setAdapter(a);

Here's append method:

public void append(List<SearchItem> values) {
        this.items.addAll(values);
}

Anything I'm missing?

+1  A: 

Don't add items to the ArrayList. Add them to the ArrayAdapter.

CommonsWare
Obviously :) This indeed worked as expected, thanks Mark
DroidIn.net