[android] smartimageview&常见的开源代码
2016-03-22 21:31
267 查看
github上搜索开源框架android-smarty-imageview,下载压缩包,拷贝我们之前写的网络图片查看器布局。
解压下载包里面的数据,找到java源码拷贝到我们的项目里,这时我们可以看到这个包下面有个SmartyImageView.java的自定义控件,SmartImageView是继承自ImageView
当我们在布局文件中使用ImageView时,可以直接写,那是因为这个类是包含在android.jar的包里面,使用自定义的时候,一定要加上包名
获取SmartImageView对象,通过findViewById()方法
调用SmartImageView对象的setImageUrl(url,fallbackResource,loadingResource)方法,参数:url是String类型的图片路径,另两个一个是下载失败时显示和正在下载时显示的int类型的资源id
解压下载包里面的数据,找到java源码拷贝到我们的项目里,这时我们可以看到这个包下面有个SmartyImageView.java的自定义控件,SmartImageView是继承自ImageView
当我们在布局文件中使用ImageView时,可以直接写,那是因为这个类是包含在android.jar的包里面,使用自定义的时候,一定要加上包名
获取SmartImageView对象,通过findViewById()方法
调用SmartImageView对象的setImageUrl(url,fallbackResource,loadingResource)方法,参数:url是String类型的图片路径,另两个一个是下载失败时显示和正在下载时显示的int类型的资源id
package com.tsh.smartimageview; import com.loopj.android.image.SmartImageView; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; 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 getInternetImg(View v){ SmartImageView siv=(SmartImageView) findViewById(R.id.siv_pic); siv.setImageUrl(et_path.getText().toString().trim(), R.drawable.ic_launcher, R.drawable.ic_launcher); } }
相关文章推荐
- Android RSA加密解密的 工具类的使用
- android富文本的应用之草稿箱
- Android图像处理之Path
- Android开发随笔之自定义TitleBar
- Android 学习笔记(一)
- Android学习笔记——数据库SQLite
- android中的动画:帧动画、补间动画、属性动画
- Android——Intent(意图)
- android日常2016-3-22 页面跳转、内容传递和返回
- Android 中对称加密算法DES,DESede,AES的加密和解密 的工具类的使用
- Android新手入门2016(13)--阻塞对话框PopupWindow
- Android CardView使用详解
- Android:ListView.addHeaderView()用法及其注意事项
- Android SwipeRefreshLayout实现下拉刷新,上拉加载、滑动加载(自动加载)和点击加载
- Android消息机制Looper与VSync的传播
- Android 中MD5算法生成字符串
- Android:控件Spinner实现下拉列表
- 安卓开发常见错误原因及解决方法
- 最流行的android组件大全
- Android_动态权限管理的解决方案