开发者

ArrayAdapter.setNotifyOnChange is not working correctly

I want to control the display of my ListView data. I am filtering and sorting before I want to display the list. The list is being refreshed before I call publishResults() as well as after I do my filtering and call publishResults().

public StoreAdapter(Context context, int textViewResourceId, ArrayList<Store> items, StoresTab storeTab) {
    super(context, textViewResourceId, items);
    this.items = ite开发者_开发问答ms;
    this.storeTab = storeTab;
    this.context = context;
    this.filter = new StoreFilter();
    imageLoader = ImageThreadLoader.getOnDiskInstance(context);
    setNotifyOnChange(false);
}

protected void publishResults(CharSequence constraint, FilterResults results) {
        // NOTE: this function is *always* called from the UI thread.
        ArrayList<Store> filtered = (ArrayList<Store>)results.values;
        clear();
        if (filtered != null)
        {
            for (int i = 0; i < filtered.size(); i++)
            {
                add(filtered.get(i));
            }
            sort(storeTab);
        }
        notifyDataSetChanged();
    }

The view is displayed before I call the filter operation. I call adater.add() method inside my ListActivity and do not call notifyDataSetChanged() anywhere else.

I'm spinning my wheels here. I do not have the source to debug it.

When I debug I can see the notifydatasetchanged property=false when the arrayAdapter.getView is called. Is there a way to find out what event is calling this to be called?


have you tried adapter.notifyDataSetChanged() instead of notifyDataSetChanged()?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜