第三方开源项目加载网络图片
2015-12-17 22:23
579 查看
github加载网络图片地址:https://github.com/loopj/android-smart-image-view
直接导入自己的项目中:
效果图:
正常加载
加载失败
当加载图片出现错误时,调用setImageUrl()的后面自定义的图片(表示错误)。
activity_main:
MainActivity:
最后加上权限。
直接导入自己的项目中:
效果图:
正常加载
加载失败
当加载图片出现错误时,调用setImageUrl()的后面自定义的图片(表示错误)。
activity_main:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.zhangli.lookPicture.MainActivity" > <com.loopj.android.image.SmartImageView android:layout_weight="1000" android:id="@+id/siv" android:layout_width="match_parent" android:layout_height="match_parent"/> <EditText android:id="@+id/et_path" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="请输入图片路径" android:singleLine="true" android:text="http://avatar.csdn.net/F/E/F/1_zhangli_.jpg" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:onClick="click" android:text="浏览" /> </LinearLayout>
MainActivity:
package com.zhangli.imageviewer; import com.loopj.android.image.SmartImageView; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.EditText; public class MainActivity extends Activity { private EditText et_path; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); et_path=(EditText) findViewById(R.id.et_path); } 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); } }
最后加上权限。
相关文章推荐
- Linux网络监控工具nethogs
- 网络基础知识-2
- 关于HTTP协议的学习
- webView 拦截网络请求
- JAVA学习第五十九课 — 网络编程概述
- 黑马程序员——网络编程之TCP
- [连载]《C#通讯(串口和网络)框架的设计与实现》- 10.宿主程序详细设计
- 黑马程序员_java网络编程
- 网络流男女配对问题java实现
- Xcode7 Http请求
- 网络流做题汇总
- iftop ---Linux网络流量监控工具
- Linux获取网络接口信息
- CCNA考试情况及心得体会
- VirtualBox的网络配置,Host Only+NAT方式
- Xcode7 网络请求报错:The resource could not be loaded because the App Transport Security policy requir
- hdu 4888 Redraw Beautiful Drawings 网络流
- 修改HttpServletRequest的参数【转】
- 判断Android 手机网络连接
- apache http service 2.4 + mod_jk + tomcat 8 集群配置总结