2

How to update gridview with new images

 2 years ago
source link: https://www.codesd.com/item/how-to-update-gridview-with-new-images.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to update gridview with new images

advertisements
adapter = new ImageAdapter(this, imagelist, imageBool, resourceName, docBool);
            adapter.NotifyDataSetChanged();
            //gridview.Adapter = null;
            gridview.InvalidateViews();
            gridview.Adapter = adapter;

I send the list with the new values to the imageadapter and it sorts the values out and returnes the items as images and alls is good. But when i want to refresh the items the old ones just stays the same and the new ones never arrives on the screen. Ive tried a lot of different ways to reload the grid but it doesn't work.


Add following methods to your customized adapter ie. ImageAdapter.

// Call it once , first time when you want to pass the data to adapter
public void setImageList(List<YOUR DATA TYPE> imagelist) {
    this.imagelist = imagelist;
}

// Call this method whenever new data is to be added to existing list.
public void updateImageList(List<YOUR DATA TYPE> newImagelist) {  

    if(this.imagelist != null){
       this.imagelist.addAll(newImagelist);
    }else{
       this.imagelist = imagelist;
    }

    notifyDataSetChanged();
}

And call it once the new data is downloaded.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK