Android 使用毕加索从url加载多个Imageview?

Android 使用毕加索从url加载多个Imageview?,android,android-layout,image-loading,picasso,Android,Android Layout,Image Loading,Picasso,我试图用毕加索加载多个ImageView,但它只加载一个ImageView。这是我的密码: public void setClassicImg(JSONArray listImg, RelativeLayout rl) throws JSONException, IOException, MalformedURLException { if (listImg.length() > 0) { DisplayMetrics metrics = new D

我试图用毕加索加载多个ImageView,但它只加载一个ImageView。这是我的密码:

    public void setClassicImg(JSONArray listImg, RelativeLayout rl) throws JSONException, IOException, MalformedURLException {
    if (listImg.length() > 0)
    {
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        for (int i = 0; i < listImg.length(); i++) 
        {

            ImageView downloadedImg = new ImageView(this);
                            //  downloadedImg.setBackgroundColor(Color.parseColor(listImg.getJSONObject(i).getString("color")));
            //      new DownloadImageTask(downloadedImg).execute(listImg.getJSONObject(i).getString("http"));

            Picasso.with(this.getApplicationContext()).load(listImg.getJSONObject(i).getString("http")).into(downloadedImg);

            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) (metrics.widthPixels * listImg.getJSONObject(i).getDouble("size_x")), (int) (metrics.heightPixels * listImg.getJSONObject(i).getDouble("size_y")));
            params.leftMargin = (int) (metrics.widthPixels * listImg.getJSONObject(i).getDouble("position_x"));
            params.topMargin = (int) (metrics.heightPixels * listImg.getJSONObject(i).getDouble("position_y"));
            downloadedImg.setScaleType(ImageView.ScaleType.FIT_XY);
            //              downloadedImg.getLayoutParams().width = BIND_ALLOW_OOM_MANAGEMENT;


            /// downloadedImg.setBackgroundDrawable(animation);
            //                  downloadedImg.setImageDrawable(animation);
            rl.addView(downloadedImg, params);
        }
    }
}
我在一个json文件中。包含图像的.png或.jpg的字符串在字符串http中,所以我得到了它,但在设备上,它只显示加载的第一个ImageView,似乎只执行了一次循环


有人知道我做错了什么吗?

我也遇到了同样的问题,毕加索只是加载了第一个,在我的情况下,我的解决方案是创建一个自定义类来处理它,所以我将URL存储在一个列表中,当加载第一个URL结束时,我开始加载下一个URL。为了不慢,我加载了所有没有目标的东西,所以它缓存了图像

@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
    //DO whatever you need with the bitmap
    urls.remove(currentUrl);
    if (urls.size() > 0) {
        currentUrl = urls.get(0);
        Picasso.with(context).load(urls.get(0)).into(this);
    }
}
以及我添加URL的方法

public void addUrl(String url) {
    urls.add(url);
    if (currentUrl.isEmpty()) {
        //this would be the first Url, so load directly
        currentUrl = url;
        Picasso.with(context).load(url).into(this);
    }
    else {
        //load to cache, than when loaded into the target it will get from memory
        Picasso.with(context).load(url);
    }
}

我也有同样的问题,有更新吗?