Android uses an open source framework to load images

Source: Internet
Author: User

Android development, sometimes need to load the network pictures, we can load through the way of the API, but a few days ago, found a good open source framework, can help us very simple and convenient to carry out the loading of images, so record.

What I'm using is: Android-smart-image-view

The address on GitHub is: Https://github.com/loopj/android-smart-image-view, we can search directly, GitHub is a treasure trove for our programmers and must be good at application.

After downloading, we copy the folder under SRC in the directory to our project, so that we can refer to the corresponding method.

Since we're going to show a whole picture, here in main.xml we need to define the components that are.

Here to see clearly, my imageview is not the system API under the ImageView but the reference to just download the open source Smartimageview, so here the component definition way to step before the same, this should be remembered.

    <com.loopj.android.image.smartimageview        android:id= "@+id/siv"        android:layout_width= "Fill_parent"        android:layout_height= "wrap_content"/>    <edittext        android:text= ""        android:id= "@+id/et_ Path "        android:layout_width=" fill_parent "        android:layout_height=" wrap_content "        android:hint=" Please enter the picture location "/>        <button        android:onclick=" click "        android:layout_width=" Fill_parent        " android:layout_height= "Wrap_content"        android:text= "browse"/>

And then acvity, we do the button click Time Implementation.

The method called here Setimageurl (String url, final integer fallbackresource, final integer loadingresource)

URL: Gets the address of the network picture.

Fallbackresource: Download failed to display picture

Loadingresource: The picture shown in the download.

  public void Click (View view) {        Smartimageview Siv = (smartimageview) Findviewbyid (R.ID.SIV);        Siv.setimageurl (Et_path.gettext (). toString (). Trim ()                , r.drawable.ic_launcher,r.drawable.ic_launcher);    }

This is very simple, we have achieved, the network image loading.

Darren

Weibo: @IT_ Siege Division

GitHub: @Darren90

Source: http://www.cnblogs.com/fengtengfei/

Android uses an open source framework to load images

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.