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