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

来源:互联网 发布:数据分析师认证含金量 编辑:程序博客网 时间:2024/05/18 02:26

源码下载↓↓↓

在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;@Overrideprotected 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>

点击下载源码
0 0
原创粉丝点击