SmartImageView初接触-创新互联

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

成都创新互联公司是一家专注于网站设计、网站制作与策划设计,芮城网站建设哪家好?成都创新互联公司做网站,专注于网站建设10余年,网设计领域的专业建站公司;建站业务涵盖:芮城等地区。芮城做网站价格咨询:18982081108

官方原版插件说明

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

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"

  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">

  <com.yuanlp.smartp_w_picpathview.loopj.android.p_w_picpath.SmartImageView
    android:id="@+id/siv"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

</LinearLayout>

在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.)}
}

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

当前标题:SmartImageView初接触-创新互联
当前地址:https://www.cdcxhl.com/article46/dhpshg.html

成都网站建设公司_创新互联,为您提供网页设计公司小程序开发ChatGPT网站策划App开发定制开发

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都网站建设公司