毕加索没有加载图片,也没有记录错误

时间:2016-03-05 01:15:52

标签: android picasso

我的用例是从URL加载图片,我正在使用毕加索,以下列方式来实现。

    ll = (LinearLayout) findViewById(R.id.tasklayout);
    ImageView imageView = new ImageView(this);
    Picasso.with(this).load(taskFieldDao.data).into(imageView);
    ll.addView(imageView, new LinearLayout.LayoutParams(800, 800));

我看到的是800 * 800的空白,其中没有图像。看着日志,似乎没有任何问题。 Atleast picasso没有录制任何内容。

2 个答案:

答案 0 :(得分:0)

我通过按钮点击复制您的问题,它正在运行。您也可以检查您的路径是否正确

 downloadButton = (Button)findViewById(R.id.download_button);

    downloadButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {                

            RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.relative);
            ImageView imageView = new ImageView(PicassoDownloadActivity.this);
            Picasso.with(PicassoDownloadActivity.this).load(Helper.imageDownloadPath).into(imageView);
            relativeLayout.addView(imageView, new LinearLayout.LayoutParams(800, 800));
        }
    });

答案 1 :(得分:0)

当出现问题时,毕加索通常不会出错,我建议这样做:

ll = (LinearLayout) findViewById(R.id.tasklayout);
final ImageView imageView = new ImageView(this);
Picasso.with(this).load(taskFieldDao.data).into(imageView, new Callback() {

    @Override
    public void onSuccess() {
        ll.addView(imageView, new LinearLayout.LayoutParams(800, 800));
   }

    @Override
    public void onError() {
        Log.e("Picasso","Image load failed);
    }
});
相关问题