Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 毕加索未将url加载到ImageView中_Java_Android_Android Studio_Picasso - Fatal编程技术网

Java 毕加索未将url加载到ImageView中

Java 毕加索未将url加载到ImageView中,java,android,android-studio,picasso,Java,Android,Android Studio,Picasso,我正在使用毕加索从url加载图像,但它没有从url加载图像,尽管我对url做了一些更改,因为它包含阿拉伯字符 MainActivity.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xml

我正在使用毕加索从url加载图像,但它没有从url加载图像,尽管我对url做了一些更改,因为它包含阿拉伯字符

MainActivity.xml

<?xml version="1.0" encoding="utf-8"?>
<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"
android:background="@color/colorAccent"
tools:context="com.alpha25.gridview.HomeActivity">



<ImageView
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:id="@+id/imageView"
    android:scaleType="centerCrop"/>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:text="Load Image"
    android:layout_centerHorizontal="true"
    android:id="@+id/load"/>
尝试以下更改:-

    imageView = (ImageView) findViewById(R.id.imageView);
    load = (Button)findViewById(R.id.load);
    String url = "https://arabian-chemistry.com/wp-content/uploads/2017/09/%D8%A7%D9%81%D8%AA%D8%B1%D8%A7%D8%B6%D9%8A%D8%A9.png";

    load.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Picasso.with(MainActivity.this).load(url).into(imageView);
试试这个,对我有用

ImageView imageView = (ImageView) findViewById(R.id.imageView);
String url =
    "https://arabian-chemistry.com/wp-content/uploads/2017/09/%D8%A7%D9%81%D8%AA%D8%B1%D8%A7%D8%B6%D9%8A%D8%A9.png";

Picasso.with(mContext).load(url).into(imageView);
只是我的演示中的这些代码,对我有用。
别忘了互联网的许可。

你能检查一下你的日志吗。有错误吗?日志中没有错误。另外,代码和url都没有问题。只需检查INTERNET权限,或检查占位符是否使用“.error()”以防出错。它将澄清没有错误。我给了互联网许可,使用方式如下:-毕加索.with(MainActivity.this).load(";您是否在Android清单文件中授予了INTERNET权限?因为它在我的手机中工作。我授予了INTERNET权限,我授予了INTERNET权限并进行了此操作,而不是在您的代码中对该url进行编码。您是否对回答做了相同的操作??不要将url编码为URI,只需按原样传递url即可。您可以使用毕加索为url设置侦听器成功和失败。实现这些侦听器,您将获得失败的原因。请,您是否可以从项目中构建apk并将其发送给我,我想看看问题是否来自模拟器或我的设备…我的电子邮件:muhammadnoamany@gmail.com@Pallavitapkir也不能和我一起工作,你能给我看看你的身材吗d您从项目中构建apk并将其发送给我,我想看看问题是否来自模拟器或我的设备…我的电子邮件:muhammadnoamany@gmail.com
Picasso.with(context)
            .load("https://arabian-chemistry.com/wp-content/uploads/2017/09/%D8%A7%D9%81%D8%AA%D8%B1%D8%A7%D8%B6%D9%8A%D8%A9.png")
            .into(image);
ImageView imageView = (ImageView) findViewById(R.id.imageView);
String url =
    "https://arabian-chemistry.com/wp-content/uploads/2017/09/%D8%A7%D9%81%D8%AA%D8%B1%D8%A7%D8%B6%D9%8A%D8%A9.png";

Picasso.with(mContext).load(url).into(imageView);