简体   繁体   中英

Cannot find get() method while using Picasso in Android

Need help with using Picasso lib in android studio. I want to use it to load image in ImageView. So i added implementation in build.gradle and this was compled to my app. But there is no "get()" or old "with()" methods.

cant see get() in the list

在列表中看不到 get()

I found it by this way:

Picasso picasso = Picasso.get() is better, but not working

Picasso picasso = Picasso.get() 更好,但不起作用

Still not working for me.

I just want the image will be loaded from phone storage. I can get the path, but dont know how to load into imageview.

EDIT: thanks for answer, but i should repeat it again, but now with your code

code from 1st answer

As you can see, it still not working.

Yes, it's implementation 'com.squareup.picasso:picasso:2.71828'. I reinstalled Android Studio and it didn't work.

EDIT 2: just attached this picture to ensure you, im using the last version.

version of Picasso

Picasso doesnt need to intialize just directly do the syntax of lib

Picasso.get()
        .load("")
        .resize(50, 50)
        .centerCrop()
        .into(imageView);

Check Picasso version switch to latest

implementation 'com.squareup.picasso:picasso:2.71828'

or try to sync again

You are probably using Picasso at class level. You should use it inside a method in OnCreate() in you are using Activity or inside OnCreateView() for Fragment .

public class MainActivity  extends Activity {
   ...

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ...

        Picasso.get()
                .load("image-resource")
                .into(imageView);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM