gpt4 book ai didi

android - picasso 没有加载图像

转载 作者:可可西里 更新时间:2023-11-01 18:49:14 27 4
gpt4 key购买 nike

这是 picasso 的代码:

ImageView img = (ImageView)findViewById(R.id.product_image);
Picasso.with(this)
.load(_url)
.fit()
.into(img, new Callback() {

@Override
public void onSuccess() {


}

@Override
public void onError() {


}
});

这是 _url 的值: http://kiagallery.ir/Images/Upload/Collection%20101/Spring%20101/d4a03b66dc7b46c694615c549b78b2e9.jpg

这是 xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ImageView
android:id="@+id/product_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:layout_below="@id/product_image"/>

<TextView
android:id="@+id/product_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:layout_below="@id/product_name"/>
</RelativeLayout>

如您所见,可以通过浏览器访问图像,但 picasso 无法加载它,我检查了 onError 函数,但从未调用过它,我在这里安静地迷路了,我们将不胜感激。

编辑: 当我给 imageview 的宽度和高度固定值(如 200dp)时,它会加载图像,但当我将其更改为 wrap_content 时,它不会显示图像。

最佳答案

不要忘记为 list 添加权限

<manifest ...>
<uses-permission android:name="android.permission.INTERNET" />

关于android - picasso 没有加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25114045/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com