简体   繁体   English

使用毕加索将图像从手机存储加载到GridView

[英]Load Images from Phone storage to GridView using Picasso

I have downloaded the images in a folder on my phone and I also have the path to those images. 我已将图像下载到手机上的文件夹中,并且也具有这些图像的路径。 How can I load all the images from that folder in a gridView using Picasso library? 如何使用Picasso库从gridView的该文件夹中加载所有图像?

UPDATE: 更新:

GridView gridView = (GridView)findViewById(R.id.gridView);
File file = new File(Environment.getExternalStorageDirectory().getPath() +"/Gallery/Mix/");
Uri uri = Uri.fromFile(file);

Now what is the next step, how can I load all the files from Mix folder to gridView? 现在下一步是什么,如何将所有文件从Mix文件夹加载到gridView?

You should follow the documentation here . 您应该在此处遵循文档。 It walks you through adding ImageViews to a GridView. 它引导您完成将ImageViews添加到GridView的过程。

Then instead of using mThumbIds as your list of resource ids you can use File[] filesArray = new file.listFiles(); 然后,可以使用File[] filesArray = new file.listFiles();而不是将mThumbIds用作资源ID列表File[] filesArray = new file.listFiles(); as your list of image files and loop through it instead. 作为图像文件列表,并循环浏览。

Then replace the line imageView.setImageResource(mThumbIds[position]); 然后替换行imageView.setImageResource(mThumbIds[position]); in ImageAdapter with Picasso.with(context).load(filesArray[position]).into(imageView); ImageAdapterPicasso.with(context).load(filesArray[position]).into(imageView); to use Picasso (got from here ). 使用毕加索(从这里获得 )。

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

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