1

I had used Picasso library in a ListView multiple times and worked fine, But now i can't use it for easy things like this sample project.

Please help

package com.example.picasso_image;

import com.squareup.picasso.Picasso;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ImageView _imageview = (ImageView) this.findViewById(R.id.imageView1);

    Picasso.with(this).load("http://i.imgur.com/DvpvklR.png").into(_imageview);

  }
}

activity_main.xml

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:id="@+id/container"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context="com.example.picasso_image.MainActivity"
   tools:ignore="MergeRootFrame" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
         />

</RelativeLayout>

1 Answers1

1

Make sure you have the correct permissions:

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

The above must be places in the correct AndroidManifest.xml file.

Also, make sure your device is connected to a network and is not in airplane mode.

stevebot
  • 23,275
  • 29
  • 119
  • 181