错误:需要:图像,已找到:图像和可Parcelable

huangapple go评论61阅读模式
英文:

Error: Required: Image, Found:Image & Parcelable

问题

[![在此输入图片描述][1]][1]

当尝试从图库中获取多个已选择图像时使用图像数组列表时出现了兼容性问题如屏幕截图所示可能的解决方案是什么

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode != RESULT_OK)
        return;
    if (requestCode == ConstantsCustomGallery.REQUEST_CODE && resultCode == Activity.RESULT_OK && data != null) {
        // 选定图像的路径存储在数组列表中
        ArrayList<Image> images = data.getParcelableArrayListExtra(ConstantsCustomGallery.INTENT_EXTRA_IMAGES);

        for (int i = 0; i < images.size(); i++) {
            Uri uri = Uri.fromFile(new File(images.get(i).path));
            // 开始使用图像 URI 进行操作

        }
    }
}

<details>
<summary>英文:</summary>

[![enter image description here][1]][1]


  [1]: https://i.stack.imgur.com/fTcYe.jpg


 While trying to get multiple selected images from gallery,  there is a compatible issue as shown in screenshot when i use image array list. What could be the solution?

     @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    
            super.onActivityResult(requestCode, resultCode, data);
    
    
            if (resultCode != RESULT_OK)
                return;
            if (requestCode == ConstantsCustomGallery.REQUEST_CODE &amp;&amp; resultCode == Activity.RESULT_OK &amp;&amp; data != null) {
                //The array list has the image paths of the selected images
                ArrayList&lt;Image&gt; images = data.getParcelableArrayListExtra(ConstantsCustomGallery.INTENT_EXTRA_IMAGES);
    
    
                for (int i = 0; i &lt; images.size(); i++) {
                    Uri uri = Uri.fromFile(new File(images.get(i).path));
                    // start play with image uri
    
                }

</details>


# 答案1
**得分**: 1

按照我在评论中所说,您需要导入正确的`Image`。

```java
import in.myinnos.awesomeimagepicker.models.Image;

而不是

import android.media.Image;
英文:

As i said in comments You need to import the right Image .

import in.myinnos.awesomeimagepicker.models.Image;

instead of

import android.media.Image;

huangapple
  • 本文由 发表于 2020年9月17日 22:25:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/63940211.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定