网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

SmartImageView初接触

最近一直在学习从远程服务器获取图片,开始时都是手写这些处理,后来接触到了smartImageview这个插件。github获取地址:https://github.com/loopj/android-smart-p_w_picpath-view

成都创新互联公司是一家从事企业网站建设、成都做网站、网站建设、行业门户网站建设、网页设计制作的专业网络公司,拥有经验丰富的网站建设工程师和网页设计人员,具备各种规模与类型网站建设的实力,在网站建设领域树立了自己独特的设计风格。自公司成立以来曾独立设计制作的站点上1000+。

官方原版插件说明

Overview

        SmartImageView is a drop-in replacement for Android’s standard ImageView which additionally allows p_w_picpaths to be loaded from URLs or the user’s contact address book. Images are cached to memory and to disk for super fast loading.

Features

    • Drop-in replacement for ImageView

    • Load p_w_picpaths from a URL

    • Load p_w_picpaths from the phone’s contact address book

    • Asynchronous loading of p_w_picpaths, loading happens outside the UI thread

    • Images are cached to memory and to disk for super fast loading

    • SmartImage class is easily extendable to load from other sources

其中用到的就是:setImageUrl()方法,该方法有好几个重载方法,用到了这个

setImageUrl(String url,int fallbackResource)

这个方法的参数解析如下:url当然是远程图片的地址,第二个参数是当获取远程图片失败时,显示的图片,是一个int类型的res下的图片的一个id

        在使用时,直接在布局文件里使用SmartImageView就行,这个类继承自ImageView


   xmlns:android="http://schemas.android.com/apk/res/android"

   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical">
   
           android:id="@+id/siv"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"/>

在MainActivity 中

com.yuanlp.smartp_w_picpathviewandroid.support.v7.app.AppCompatActivityandroid.os.Bundlecom.yuanlp.smartp_w_picpathview.loopj.android.p_w_picpath.SmartImageViewMainActivity AppCompatActivity {

    (Bundle savedInstanceState) {
        .onCreate(savedInstanceState)setContentView(R.layout.)SmartImageView siv=(SmartImageView) findViewById(R.id.)siv.setImageUrl(R.drawable.)}
}


当前标题:SmartImageView初接触
文章URL:http://bjjierui.cn/article/ijhhog.html

其他资讯