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

来源:互联网 发布:密度聚类算法 编辑:程序博客网 时间:2024/05/22 13:26

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;@Overrideprotected 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目录下






文档上的使用方法:


原创粉丝点击