Android Smart Image View使用方法--从url获取图片或从通讯录获取图片,支持缓存

Android Smart Image View------Load Images from URLs or Android Contacts with Caching


一、下载http://loopj.com/android-smart-image-view/

解压下载的文件,将 com目录复制你自己的工程src目录下或者也可以将 下载的 jar文件放到你的 libs目录下

注:链接里有使用方法


二、

package com.jiangge.imageviewerusesmartview;

import com.loopj.android.image.SmartImageView;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends Activity {

	SmartImageView mySmartView; 
	EditText it_url;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		it_url = (EditText) findViewById(R.id.it_path);
		mySmartView = (SmartImageView) findViewById(R.id.my_smart_image_view);
	}
	
	public void click(View view){
		mySmartView.setImageUrl(it_url.getText().toString().trim());
		
		Log.i("URL", it_url.getText().toString().trim());
	}

}


核心代码:

mySmartView = (SmartImageView) findViewById(R.id.my_smart_image_view);


mySmartView.setImageUrl(it_url.getText().toString().trim());



三、XML文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <com.loopj.android.image.SmartImageView
        android:id="@+id/my_smart_image_view"
        android:layout_weight="1000"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:text="@string/hello_world" />

    <EditText
        android:id="@+id/it_path"
        android:singleLine="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="http://g.hiphotos.baidu.com/image/w%3D2048/sign=fa4ce6add31b0ef46ce89f5ee9fc50da/f636afc379310a55ed977077b64543a983261085.jpg"
        android:hint="图片路径" >
    </EditText>

    <Button
        android:id="@+id/btn"
        android:onClick="click"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="发送请求" >
    </Button>

</LinearLayout>


核心代码:

<com.loopj.android.image.SmartImageView





四、效果图:




解压下载的文件,将 com目录复制你自己的工程src目录下






文档上的使用方法:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值