android 安卓毕加索我怎么才能加载图像

wi3ka0sx  于 2023-02-02  发布在  Android
关注(0)|答案(1)|浏览(137)

在构建中添加.gradle库picasso在清单文件中添加权限将ImageView添加到MainActivity中的布局

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ImageView imageView = (ImageView) findViewById(R.id.imageView);
        String urlPath = "http://217.175.38.5:53389/photo/employee/262421?lastmod=1649263637";

        Glide
                .with(this)
                .load(urlPath)
                .into(imageView);

       Picasso
               .get()
               .load(urlPath)
               .into(imageView);

    }

我决定试试滑翔,但它不太管用

eqoofvh9

eqoofvh91#

因为您必须使用https加载url或在清单中添加此行

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        ...
        android:usesCleartextTraffic="true"
        ...>
        ...
    </application>
</manifest>

相关问题