简体   繁体   English

Android-将大量图像加载到GridView上

[英]Android - Loading large sets of images onto GridView

I'm developing an Android app which needs to display the phone's images onto a GridView. 我正在开发一个Android应用,该应用需要将手机的图像显示到GridView上。 What I need to do is to load those images asynchronously, and don't have the user to wait until all the photos have been loaded. 我需要做的是异步加载这些图像,而不必让用户等待所有照片都已加载。 What's the best way to do this, by using a CursorLoader or an AsyncTaskLoader maybe? 最好的方式是通过使用CursorLoader或AsyncTaskLoader来做到这一点?

Thanks in advance. 提前致谢。

I highly recommend you Picasso : http://square.github.io/picasso/ 我强烈建议您使用Picassohttp : //square.github.io/picasso/

It's a perfect library to load images with asynchronous thread. 它是使用异步线程加载图像的理想库。

You can load your image in your adapter with: 您可以使用以下方法将图像加载到适配器中:

Picasso.with(yourContext).load("http://yoururl.com/yourimage.png").into(yourImageView);

After trying to implement this on my own and coming across all kinds of problem which have already been solved by others i went on using Picasso. 在尝试自己实现这一点并遇到其他人已经解决的各种问题之后,我继续使用毕加索。

You load images in 1 line of code: 您以1行代码加载图像:

Picasso.with(context).load(imageUrl).into(imageView_XY);

http://square.github.io/picasso/ http://square.github.io/picasso/

Alternative: 选择:

https://github.com/nostra13/Android-Universal-Image-Loader https://github.com/nostra13/Android-Universal-Image-Loader

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM