android GridView加载图片,一张张显示

简单说下,获取SDcard里的图片或者视屏缩略图就不说了,网上很多,主要写下加载图片的方式,在Grideview的Adapter中getView()方法中定义:

//异步加载图片,实现一张张显示

new LoadImageAsyctask(gridViewHold.icon).execute(paths[position]);


class LoadImageAsyctask extends AsyncTask<String, Void, Bitmap>{

ImageView view;


public LoadImageAsyctask(ImageView view) {

super();

this.view = view;

}


@Override

protected Bitmap doInBackground(String... params) {

// TODO Auto-generated method stub

Bitmap videoIcon = ThumbnailUtils.createVideoThumbnail(

params[0], Video.Thumbnails.MINI_KIND);

return videoIcon;

}


@Override

protected void onPreExecute() {

// TODO Auto-generated method stub

super.onPreExecute();

}


@Override

protected void onPostExecute(Bitmap result) {

// TODO Auto-generated method stub

this.view.setImageBitmap(result);

super.onPostExecute(result);

}

}



android GridView加载图片,一张张显示,布布扣,bubuko.com

android GridView加载图片,一张张显示

上一篇:iOS系统网络抓包方法


下一篇:苹果新的编程语言 Swift 语言进阶(一)--综述