Android - picasso shows only placeholder, not the image from URL

ぐ巨炮叔叔 提交于 2019-12-04 03:53:50

问题


I've got this code

public class MainActivity extends Activity {

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

        ImageView image_view = (ImageView)findViewById(R.id.imageView1);

        Picasso.with(getApplicationContext()).load("http://nuclearpixel.com/content/icons/2010-02-09_stellar_icons_from_space_from_2005/earth_128.png").placeholder(R.drawable.ic_launcher).noFade().into(image_view);
    }

And i want to view the image from url in my imageview... however instead of the image only the placeholder shows. What may be the problem?


回答1:


Try using just picasso.load() instead of Picasso.with()

Something like this:

Picasso.Builder builder = new Picasso.Builder(getApplicationContext());
Picasso picasso = builder.build();
picasso.load("http://nuclearpixel.com/content/icons/2010-02-09_stellar_icons_from_space_from_2005/earth_128.png").placeholder(R.drawable.ic_launcher).noFade().into(image_view);


来源:https://stackoverflow.com/questions/25782224/android-picasso-shows-only-placeholder-not-the-image-from-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!