您的位置:首页 > 移动开发 > Android开发

Android SmartImageView插件实现图片浏览功能

2014-05-02 17:04 861 查看
源码下载↓↓↓

在https://github.com网上找的小插件,实现图片浏览的简单功能,很方便。



额,简单的代码都没有几个了、、

package com.example.imageview;

import com.loopj.android.image.SmartImageView;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends Activity {

EditText editText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText = (EditText) findViewById(R.id.editText1);
}

public void click(View view){
SmartImageView image = (SmartImageView) findViewById(R.id.textView1);
image.setImageUrl(editText.getText().toString().trim(), R.drawable.ic_launcher, R.drawable.ic_launcher);
}
}
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<com.loopj.android.image.SmartImageView
android:id="@+id/textView1"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="1"
android:text="http://img0.bdstatic.com/img/image/shouye/mvznns.jpg"
android:ems="10" >

<requestFocus />
</EditText>

<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="click"
android:text="查看" />

</LinearLayout>

点击下载源码
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android 图片