zoukankan      html  css  js  c++  java
  • [android] smartimageview&常见的开源代码

    github上搜索开源框架android-smarty-imageview,下载压缩包,拷贝我们之前写的网络图片查看器布局。

    解压下载包里面的数据,找到java源码拷贝到我们的项目里,这时我们可以看到这个包下面有个SmartyImageView.java的自定义控件,SmartImageView是继承自ImageView

    当我们在布局文件中使用ImageView时,可以直接写,那是因为这个类是包含在android.jar的包里面,使用自定义的时候,一定要加上包名

    获取SmartImageView对象,通过findViewById()方法

    调用SmartImageView对象的setImageUrl(url,fallbackResource,loadingResource)方法,参数:urlString类型的图片路径,另两个一个是下载失败时显示和正在下载时显示的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);
        }
    }
  • 相关阅读:
    mas_makeConstraints && mas_remakeConstraints && mas_updateConstraints 用法与注意事项
    iOS特性一 关闭系统日志打印
    React-Native -课后练习
    RN 项目导入WebStorm 组件没有依赖
    React-Native需要css和布局-20160902
    方式 隐藏导航栏
    svn status状态
    spring整合redis
    maven编译跳过TEST
    linux自动登录脚本expect
  • 原文地址:https://www.cnblogs.com/taoshihan/p/5308593.html
Copyright © 2011-2022 走看看