安卓开发-利用smart-image-view来实现网络中的图片在手机上的显示
来源:互联网 发布:中国移动视频软件 编辑:程序博客网 时间:2024/05/22 03:13
1.在项目中导入smart-image-view的文件如图:
2.在activity_main.xml中,引入SmartImageView:
<com.loopj.android.image.SmartImageView android:id="@+id/siv" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
3.在MainActivity中进行网络请求(http://10.0.2.2:8080/img/a1.png,自定义在tomcat服务器下的webapps/ROOT下有一个文件夹img,里面有图片a1.png,10.0.2.2是安卓手机访问tomcat的映射地址,localhost或者电脑ip都不行):
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SmartImageView siv = (SmartImageView)findViewById(R.id.siv); //访问失败显示drawable/ic_launcher图片 siv.setImageUrl("http://10.0.2.2:8080/img/a1.png", R.drawable.ic_launcher); }
4.在AndroidManifest.xml中添加网络访问权限:
<uses-permission android:name="android.permission.INTERNET"/>
阅读全文
0 0
- 安卓开发-利用smart-image-view来实现网络中的图片在手机上的显示
- 安卓开发-手机上显示tomcat中的图片
- Android-smart-image-view加载网络图片
- Android学习(35) -- smart-image-view 获取网络图片
- 使用网络源码框架-图片查看器-smart-image-view
- 用Android Smart Image View做的一个网络图片浏览的Demo
- android 实现从网络上抓取图片并显示在手机上
- 聊天界面自定义cell中的image view加载网络图片不显示
- Androidx学习笔记(31)--- android-smart-image-view查看网络图片
- 在Ubuntu手机上利用Map API来显示地图并动态显示标记
- android中的布局(四) 图片在手机上显示出现乱条纹的 问题
- 利用Chrome在pc端调试安卓手机上的网页
- 获取网络上的图片,并显示在界面上的简单实现
- 根据图片的路径删除显示在view中的图片
- 安卓开发下载图片保存到手机后图片没在相册看到的问题
- Image图片在控件中的显示方式
- 安卓显示网络图片
- 利用安卓手机的OTG共享有线网络
- JSP面试题及答案
- 1083:十->二进制转换
- scala模式匹配·
- saltstack--批量安装nginx
- c++中虚表指针与虚函数详解
- 安卓开发-利用smart-image-view来实现网络中的图片在手机上的显示
- 学习笔记之面向对象编程17(容器之Comparable接口,Map接口)
- Android 开发,启动
- 解决自定义actionbar 两边空隙
- [LeetCode] 100.Same Tree
- ES6的新特性
- 算法总览
- HDU
- 1114:数列 问题