Github image loading framework glide usage introduction,

Source: Internet
Author: User

Github image loading framework glide usage introduction,
Introduction:

Glide is a library on Android that focuses on image loading and caching.


Step 1: import a package


Open the build. gradle file in the project directory and enter the following code:

repositories {    mavenCentral()}dependencies {    compile fileTree(include: ['*.jar'], dir: 'libs')    compile 'com.android.support:appcompat-v7:22.1.1'    compile 'com.github.bumptech.glide:glide:3.6.0'}


Tip: if the error "Android Studio fails to debug with error org. gradle. process. internal. ExecException" is reported, add the red box code.



Ii. Call

Single ImageView call

ImageView imageView = (ImageView) findViewById(R.id.iv_glide);Glide.with(this).load("http://img2.niushe.com/upload/201304/19/14-22-45-63-26144.jpg").into(imageView);


Adapter call

@Overridepublic View getView(int position, View recycled, ViewGroup container) {    final ImageView myImageView;    if (recycled == null) {        myImageView = (ImageView) inflater.inflate(R.layout.my_image_view,                container, false);    } else {        myImageView = (ImageView) recycled;    }    String url = myUrls.get(position);    Glide.with(myFragment)        .load(url)        .centerCrop()        .placeholder(R.drawable.loading_spinner)        .crossFade()        .into(myImageView);    return myImageView;}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.