Android使用开源框架加载图片
2023-09-11 14:16:42 时间
Android开发时,有时候需要们来加载网络图片,我们可以通过api的方式进行加载,但是前几天做的时候,发现了一个优秀的开源框架,可以帮助我们非常简单便捷的进行图片的加载,所以记录一下。
我所用的是:
android-smart-image-view
在github上的地址是:https://github.com/loopj/android-smart-image-view,我们可以直接进行搜索,github对于我们程序员来说简直是宝库啊,一定要能够擅长应用。
下载下来后,我们把其目录下的src下的以com开头的文件夹拷贝到我们工程中,这样我们就能引用相应的方法了。
由于我们要显示一整图片,所以这里在main.xml中我们需要定义的组件是。
这里要看清楚,我的imageview不是系统api下的imageview而是引用的刚才下载的开源的smartimageview,所以这里的组件定义方式步以前的不一样,这要能记着。
<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="请输入图片位置" /> <Button android:onClick="click" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="浏览" />
然后再acvity中,我们这样进行按钮点击时间的实现。
这里调用的方法setImageUrl(String url, final Integer fallbackResource, final Integer loadingResource)
url:获取网络图片的地址。
fallbackResource:下载失败显示的图片
loadingResource:下载中显示的图片。
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); }
这样很简单的,我们就实现了,网络图片的加载。
作者:Darren
微博:@IT_攻城师
github:@Darren90
出处:http://www.cnblogs.com/fengtengfei/
相关文章
- Android 开源框架ViewPageIndicator 和 ViewPage
- Android开源框架ViewPageIndicator和ViewPager实现Tab导航
- [Android Pro] android Flag介绍
- android gif动画开源框架android-gif-drawable
- Android API之android.provider.ContactsContract.Contacts
- 134、直接拿来用,Android界最火的开源项目
- Android[第三方or官方]高质量实用【组件&开源项目&框架】集合贴
- 基于EasyDarwin EasyPusher实现Android手机直播推送功能
- Android开发学习---使用Intelij idea 13.1 进行android 开发
- Android Skia和2D图形系统 .
- 《android开发艺术探索》读书笔记(十)--Android的消息机制
- 【VLC-Android】vlc-android简例
- macos安装android studio(Android Studio 2021.1.1)
- 如何在Android平台上创建自定义的Cordova插件并使用SAP UI5消费
- Android做分页加载的思路
- Android 系列讲解(数据篇)开源的数据库ORM框架之greenDAO的详解与用法
- 【Android 逆向】代码调试器开发 ( 等待进程状态改变 | detach 脱离进程调试 PTRACE_DETACH | 调试中继续运行程序 PTRACE_CONT )
- 常用Android开源框架
- android的logcat详细用法
- Android 开源框架Universal-Image-Loader完全解析(一)--- 基本介绍及使用
- Android Preference简单使用步骤
- Android多媒体开发-- android中OpenMax的实现整体框架
- Android音频框架笔记 - 下篇
- android开源项目学习
- android键盘锁定问题
- Android开源client之LookAround学习(一)Application & 网络框架
- android 输入法如何启动流程_Android输入法显示流程
- Android kotlin 第三方项目开源弹窗库 - XPopup
- Android Studio 怎么打开项目后自动打开一个新窗口