学习 smartImageView 笔记

开源项目: https://github.com/loopj/android-smart-image-view

下载完毕放入项目文件中

布局文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
	<com.loopj.android.image.SmartImageView
	    android:id="@+id/img_id"
	    android:layout_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
	    />
    <EditText
        android:id="@+id/et"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="http://img13.360buyimg.com/cms/s250x250_jfs/t484/283/320137545/96692/88416a2d/545dd66cNca8cf305.jpg" />
    <Button 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="获取tupian"
        android:onClick="click"/>

</LinearLayout>



主文件


package com.look.pic2;

import com.loopj.android.image.SmartImageView;

import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.os.Build;

public class MainActivity extends Activity {
	private EditText et;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		et = (EditText) findViewById(R.id.et);
	}
	
	public void click(View view)
	{
		SmartImageView simg = (SmartImageView) findViewById(R.id.img_id);
		String url = et.getText().toString().trim();
		simg.setImageUrl(url, R.drawable.ic_launcher, R.drawable.ic_launcher);
	}
}

清单文件 增加网络权限

    <uses-permission android:name="android.permission.INTERNET"/>

你可能感兴趣的:(学习 smartImageView 笔记)