加载位图需要很长时间



所以我正在制作一个显示捕获图像的应用程序。我首先将快照的图像保存在静态的字符串数组列表中(在下面的代码中:methods.locationPath(,然后将这些字符串转换为位图并将它们保存在位图的数组列表中(在下面的代码中:图像(。

for (String path : methods.locationPath) {
Bitmap bitmap = BitmapFactory.decodeFile(path);
images.add(bitmap);
}
gr = (GridView) findViewById(R.id.grid);
GridAdapter gridAdapter = new GridAdapter(this, values,images);
gr.setAdapter(gridAdapter);

但是,此方法需要很长时间。有没有办法通过尽可能小的更改使这个循环更快?

谢谢

而不是将图像路径更改为位图对象。您可以直接传递图像的路径,并在适配器类上将图像设置为类似

Picasso.with(mContext).load(new File(imageUrl)).resize(100,100).into(myViewHolder.imageView, new Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError() {
}
});

最新更新