how to set image from url for imageView

后端 未结 10 1752
礼貌的吻别
礼貌的吻别 2020-11-28 08:18

I wanna set Image in ImageView using Url for example I have this url

http://www.google.iq/imgres?hl=en&biw=1366&bih=667&tbm=isch&tbni

相关标签:
10条回答
  • 2020-11-28 08:34

    With the latest version of Picasso (2.71828 at the time of writing this answer), the with method has been deprecated.

    So the correct way would be-

    Picasso.get().load("https://<image-url>").into(imageView);
    

    where imageView is the ImageView you want to load your image into.

    0 讨论(0)
  • 2020-11-28 08:37

    Try:

    URL newurl = new URL(photo_url_str); 
    mIcon_val = BitmapFactory.decodeStream(newurl.openConnection() .getInputStream()); 
    profile_photo.setImageBitmap(mIcon_val);
    

    More from

    1) how-to-load-an-imageview-by-url-in-android.

    2) android-make-an-image-at-a-url-equal-to-imageviews-image

    0 讨论(0)
  • 2020-11-28 08:45

    Try the library SimpleDraweeView

    <com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/badge_image"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true" />
    

    and now you can simply do:

     final Uri uri = Uri.parse(post.getImageUrl());
    
    0 讨论(0)
  • 2020-11-28 08:47

    Try this :

    ImageView imageview = (ImageView)findViewById(R.id.your_imageview_id);
    Bitmap bmp = BitmapFactory.decodeFile(new java.net.URL(your_url).openStream());  
    imageview.setImageBitmap(bmp);
    

    You can also try this : Android-Universal-Image-Loader for efficiently loading your image from URL

    0 讨论(0)
  • 2020-11-28 08:49

    easy way to use Aquery library it helps to get direct load image from url

    AQuery aq=new AQuery(this); // intsialze aquery
     aq.id(R.id.ImageView).image("http://www.vikispot.com/z/images/vikispot/android-w.png");
    
    0 讨论(0)
  • 2020-11-28 08:50

    Using Glide library:

    Glide.with(context)
      .load(new File(url)
      .diskCacheStrategy(DiskCacheStrategy.ALL)
      .into(imageView);
    
    0 讨论(0)
提交回复
热议问题