界面效果
应用的权限
<uses-permission android:name="android.permission.INTERNET"/>
布局文件
<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/siv" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="100" /> <EditText android:id="@+id/et_path" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="请输入图片地址" android:singleLine="true" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="checkImage" android:text="@string/bt_catchImage" /> </LinearLayout>
package com.examp.use_android_smart_image_view; 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 { private EditText et_path; private SmartImageView siv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); et_path = (EditText) findViewById(R.id.et_path); et_path.setText("http://c.hiphotos.baidu.com/image/w%3D310/sign=1ebfb751a6c27d1ea5263dc52bd4adaf/78310a55b319ebc47dc5736c8026cffc1f171681.jpg"); } public void checkImage(View view) { siv = (SmartImageView) findViewById(R.id.siv); // 加载的路径|如果没有加载到显示的内容|等待加载的图片 siv.setImageUrl(et_path.getText().toString().trim(), R.drawable.ic_launcher, R.drawable.ic_launcher); } }
下载地址:
使用Android-smart-image-view加载网络图片,布布扣,bubuko.com
使用Android-smart-image-view加载网络图片
原文:http://blog.csdn.net/u011936142/article/details/27679701