【问题标题】:Universal image Loader : Open actual size image on click of an imageview inside listview通用图像加载器:单击列表视图中的图像视图打开实际大小的图像
【发布时间】:2014-07-25 23:20:29
【问题描述】:

我正在使用通用图像加载器将图像绑定到我的listview 中的ImageView。这些图像是在异步绑定时从在线 url 获取的。现在我想在点击ImageView 时打开实际大小的图像。绑定时我是否必须缓存图像,或者我可以使用imageView 源来调用将处理显示图像的意图。 我有以下代码可以打开设备上的任何图像:

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri imgUri = Uri.parse("file://" + yourfilepath);
intent.setDataAndType(imgUri, "image/*");
startActivity(intent);

listview的点击事件中,我可以在用户的​​默认图像查看器应用程序中简单地显示使用通用图像加载器加载的图像。

【问题讨论】:

  • 如果您使用通用图像加载器的 DisplayImageOptions,您的图像将被缓存。这样就可以使用通用加载器的displayimage来加载图片的url imageLoader.displayImage(your_url, your_imageview, your_options);

标签: android image listview universal-image-loader


【解决方案1】:

如果您使用通用图像加载器的 DisplayImageOptions,您的图像将被缓存。这样就可以使用通用加载器的displayimage来加载图片的url了

ImageLoader imageLoader = ImageLoader.getInstance();
DisplayImageOptions options;
imageLoader.init(ImageLoaderConfiguration.createDefault(context));
        options = new DisplayImageOptions.Builder()
                .showImageOnLoading(R.drawable.img_default)
                .showImageForEmptyUri(R.drawable.img_default)
                .showImageOnFail(R.drawable.img_default).cacheInMemory(true)
                .cacheOnDisk(true).considerExifParams(true).build();
imageLoader.displayImage(your_url, your_imageview, options);

您使用自己的活动和图像视图来显示图像。您可以通过 extras 发送 url 并使用 displaymage() 将 url 加载到图像视图中。

【讨论】:

  • 如果我的图像正在被缓存,那么我不能访问缓存图像的本地路径,然后触发可以从本地路径显示图像的意图吗?因为我更喜欢通过用户的图库应用或任何其他默认应用显示完整图像。
  • 你可以这样做.. 但是使用 url 是一个简单的。但是使用默认应用程序就很难了。
  • 好的,如果我使用 imageLoader.displayImage 在新 Activity 中显示图像,那么使用 Url 那么它将从 url 或本地缓存中获取图像?
猜你喜欢
  • 2015-10-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-01
  • 1970-01-01
相关资源
最近更新 更多