Reputation: 129
For some reason Picasso is not loading image from URLs. I just see a blank white screen. I have already tried doing solutions to previous questions like these but nothing works for me.
Here is the Java code of Activity:
public class MainActivity extends AppCompatActivity {
ImageView mImageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mImageView = (ImageView) findViewById(R.id.picassoImage);
Picasso.with(this).load("https://futurestud.io/images/books/picasso.png").into(mImageView);
}
}
And here is the XML layout code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.sourabh.usingpicasso.MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/picassoImage"/>
</LinearLayout>
Note:-
I tried with different URLs but no luck.
I have already set the permission for Internet in Manifest.XML
When I chain the error
with Picasso.with(this).load("https://futurestud.io/images/books/picasso.png").into(mImageView)
(ie
Picasso.with(this).load("https://futurestud.io/images/books/picasso.png") .error(R.drawable.ic_launcher_background). into(mImageView);
) and pass to it an Image from the drawable, the drawable image is displayed. Seems that Picasso is not loading image from URLs only.
Upvotes: 1
Views: 3065
Reputation: 3322
You should use new version : implementation 'com.squareup.picasso:picasso:2.71828'
Old Use:
Picasso.with(applicationContext).load(intent.getStringExtra(FLAG))
.into(binding.ivCountryPoster)
New Use:
Picasso.get().load(intent.getStringExtra(FLAG))
.into(binding.ivCountryPoster)
It's worked.
Upvotes: 0
Reputation: 159
Even I was facing this issue on Android Emulator (Device: Pixel 3a XL) and after like few hours trying to fix this, and then I ran the app on the real device the images were being loaded
Upvotes: 0
Reputation: 875
Please check https://github.com/square/picasso for Picasso library in details.
Maybe you are using the previous version. Please add following line in your app level build.gradle file.
implementation 'com.squareup.picasso:picasso:2.71828'
Then in your activity do this.
public class MainActivity extends AppCompatActivity {
ImageView mImageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mImageView = (ImageView) findViewById(R.id.picassoImage);
Picasso.get()
.load("https://futurestud.io/images/books/picasso.png")
.placeholder(R.drawable.placeholder_image)
.error(R.drawable.error_image)
.into(mImageView);
}
}
Upvotes: 0