【发布时间】:2020-04-13 02:42:46
【问题描述】:
我正在使用 Picasso Library 从 URL 加载图像,但它不起作用,我尝试了多个 URL,即使他们在他们的官方网站上提到了 http://i.imgur.com/DvpvklR.png
然后我尝试从资源目录加载可绘制图像,它也没有加载我所看到的只是空白屏幕没有错误没有。有人可以提出什么问题吗?
- 我已获得 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,如果此信息有帮助的话。
【问题讨论】:
-
没有没有工作,调试中也没有发现任何问题。