這篇推薦一個WebImageView來處理網路顯示圖片的問題
作者整合了常見的顯示網路功能, 像是cache, 網路下圖等等...
這篇就介紹如何使用ZaBlanc的WebImageView
1. 首先到GitHub下載https://github.com/ZaBlanc/WebImageView
開放的原碼lib
2. 完成後解壓縮, 匯入Eclipse專案, 作者當時是用Eclipse寫的, Android Studio可以使用
匯入JAR檔或是原始碼或者轉檔方式來作
3. 之後新創一個專案, 並且將剛匯入的Lib連結加入, 如下圖
4. 然後在AndroidManifest.xml加入INTERNET權限
5. 在layout下加入對方寫好的字定原件
<com.raptureinvenice.webimageview.image.WebImageView
android:id="@+id/my_img"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00000000" />
6. 然後在onCreate下, 找到該元件並且用.setImageWithURL(網址)來使用
WebImageView myImage = (WebImageView)findViewById(R.id.my_img);
myImage.setImageWithURL(this, "http://raptureinvenice.com/images/samples/pic-2.png");
7. 最後將程式載入, 就可以看到結果了