Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Picasso not loading the image

here's the code for 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() {


        }
    });

here's the value of _url: http://kiagallery.ir/Images/Upload/Collection%20101/Spring%20101/d4a03b66dc7b46c694615c549b78b2e9.jpg

and here's the 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>

as you can see the image can be accessed via browser but picasso fails to load it, I've checked the onError function and it's never called, I'm quiet lost here, any help would be appreciated.

EDIT: When I give imageview's width & height fixed value like 200dp, it loads the image, but when I change it to wrap_content it doesn't show the image.

like image 977
arash moeen Avatar asked Aug 04 '14 07:08

arash moeen


People also ask

How do you load an image into an imageView from an image URL using Picasso?

Image loading using Picasso is very easy, you can do it like this way Picasso. get(). load("http://i.imgur.com/DvpvklR.png").into(imageView); and in their website you can get every details. In your case you can parse every image URL and use RecyclerView to show them along with Picasso.

What is the latest version of Picasso library?

The latest version is 2.71828.

What is Picasso in Android Studio?

Images add much-needed context and visual flair to Android applications. Picasso allows for hassle-free image loading in your application—often in one line of code! Picasso. get(). load("https://i.imgur.com/DvpvklR.png").into(imageView);


1 Answers

Do not forget add permission to manifest

<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" /> 
like image 148
Defuera Avatar answered Sep 19 '22 07:09

Defuera