Android Studio中的毕加索库未从URL加载图像,也未从可绘制资源文件加载

问题描述 投票:0回答:1

我正在使用Picasso Library从URL加载图像,但是它不起作用,即使他们在其官方网站http://i.imgur.com/DvpvklR.png上提到了它们,我也尝试了多个URL>

然后我尝试从资源目录加载可绘制图像,它也没有加载我所看到的全部是黑屏,没有错误,没有。有人可以建议出什么问题吗?

  • 我已获得Internet许可。
  • 我使用了来自Github的最新版本的毕加索。
  • 这里是代码。

活动Java文件:


import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;

public class Main2Activity extends AppCompatActivity {

    ImageView iv2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        iv2 = findViewById(R.id.iv2);
        Picasso.get().load(R.drawable.ic_terrain_black_24dp).into(iv2);
    }
}

活动布局:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Main2Activity">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:id="@+id/iv2"
        android:contentDescription="@string/app_name"

        />

</RelativeLayout>

毕加索实现:implementation 'com.squareup.picasso:picasso:2.71828'

顺便说一下,如果此信息有帮助,我的最低SDK版本为16,目标SDK为当前的默认29。

[我正在使用Picasso Library从URL加载图像,但是它不起作用,即使他们在其官方网站http://i.imgur.com/DvpvklR.png上提到了它们,我也尝试了多个URL,然后我尝试了.. 。

android picasso
1个回答
0
投票

尝试使用占位符和错误图像。

© www.soinside.com 2019 - 2024. All rights reserved.