开发者

Refreshing base adapter with Vector of elements (Android)

I have Vector of elements that i set into BaseAdapter subclass and this adapter works with this elements

I need to refresh my list, so i set new vector to my adapter class and call adapter.notifyDataSetChanged(); method but it doesent work.

how can i fix it

UPDT:

Here is code of my refreshing method

public void updateGroups(P开发者_Python百科age page) {
        this.page = page;
        listView = (ListView)findViewById(R.id.groups_list);
        SelectGroupsListAdapter adapter =(SelectGroupsListAdapter)listView.getAdapter();
        adapter.setGroups(page.getItems());
        listView.invalidate();
        adapter.notifyDataSetChanged();



    }


I assume that adapter.setGroups(page.getItems()); add the objects to the adapter, and you are in a ListActivity, so, did you try this:

((SelectGroupsListAdapter )getListAdapter()).notifyDataSetChanged();

or

((SelectGroupsListAdapter )listAdapter).notifyDataSetChanged();

if your setGroups(page.getItems()) set a new vector be sure to add explicitly each vector element:

the adapter inner method: setGroups(...)

public void setGroups(List<?> newData){
  for(Object o : newData){
    add(o);
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜