zoukankan      html  css  js  c++  java
  • android ImageLoader加载本地图片的工具类

    import android.widget.ImageView;
    
    import com.nostra13.universalimageloader.core.ImageLoader;
    
    /**
     * 异步加载本地图片工具类
     * 
     * @author tony
     * 
     */
    public class LoadLocalImageUtil {
        private LoadLocalImageUtil() {
        }
    
        private static LoadLocalImageUtil instance = null;
    
        public static synchronized LoadLocalImageUtil getInstance() {
            if (instance == null) {
                instance = new LoadLocalImageUtil();
            }
            return instance;
        }
    
        /**
         * 从内存卡中异步加载本地图片
         * 
         * @param uri
         * @param imageView
         */
        public void displayFromSDCard(String uri, ImageView imageView) {
            // String imageUri = "file:///mnt/sdcard/image.png"; // from SD card
            ImageLoader.getInstance().displayImage("file://" + uri, imageView);
        }
    
        /**
         * 从assets文件夹中异步加载图片
         * 
         * @param imageName
         *            图片名称,带后缀的,例如:1.png
         * @param imageView
         */
        public void dispalyFromAssets(String imageName, ImageView imageView) {
            // String imageUri = "assets://image.png"; // from assets
            ImageLoader.getInstance().displayImage("assets://" + imageName,
                    imageView);
        }
    
        /**
         * 从drawable中异步加载本地图片
         * 
         * @param imageId
         * @param imageView
         */
        public void displayFromDrawable(int imageId, ImageView imageView) {
            // String imageUri = "drawable://" + R.drawable.image; // from drawables
            // (only images, non-9patch)
            ImageLoader.getInstance().displayImage("drawable://" + imageId,
                    imageView);
        }
    
        /**
         * 从内容提提供者中抓取图片
         */
        public void displayFromContent(String uri, ImageView imageView) {
            // String imageUri = "content://media/external/audio/albumart/13"; //
            // from content provider
            ImageLoader.getInstance().displayImage("content://" + uri, imageView);
        }
    
    }
  • 相关阅读:
    数字证书原理(转)
    python update from 2.6 to 2.7
    python uwsgi 部署以及优化
    uWSGI配置(转 )
    Python程序的性能分析指南(转)
    mysql 暴力破解 root账号密码
    VMware虚拟机实用经验总结十一条
    小技巧之指定refer
    cookie和session
    web相关
  • 原文地址:https://www.cnblogs.com/tony-yang-flutter/p/3986157.html
Copyright © 2011-2022 走看看