how to use gridview in onPostexecute AsyncTask

北城以北 提交于 2019-12-02 02:56:19

Add a new method in your adapter class like this

public class GridViewAdapter extends BaseAdapter{

    private ArrayList<ImageItem> mItemList;

    public void updateItemList(ArrayList<ImageItem> newItemList){
        this.mItemList = newItemList;
        notifyDataSetChanged();
    }

}

and onPostExecute call this methode and set new list. So your onPost looks like this

protected  void onPostExecute(Object result)
        {
          String data = (String)result;       
            Gson g = new Gson();
            Type t = new TypeToken<appmodel[]>(){}.getType();
            appmodel[] appm = (appmodel[])g.fromJson(data,t);
            gridAdapter.updateItemList(getData());         


        }

To load imagview using url you can use Picasso Library , for your refrence it looks like this

Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);

add following dependency to use picasso

compile 'com.squareup.picasso:picasso:2.5.2'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!