ImgActivity.java

package com.example.a20200712; import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.util.DisplayMetrics;import android.util.Log;import android.view.View;import android.view.ViewGroup;import android.widget.EditText;import android.widget.ImageView;import android.widget.Toast; import androidx.annotation.Nullable;import androidx.appcompat.app.AppCompatActivity; import com.bumptech.glide.Glide; import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStream;import java.net.HttpURLConnection;import java.net.MalformedURLException;import java.net.ProtocolException;import java.net.URL; public class ImgActivity extends AppCompatActivity {     private EditText imgPath;    private ImageView img;     @Override    protected void onCreate(@Nullable Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.img_view_layout);        imgPath = findViewById(R.id.img_layout_imgText);        img = findViewById(R.id.img_layout_img);    }     public void imgviewonClick(View view) {        Glide.with(ImgActivity.this).load(imgPath.getText().toString()).into(img);    } }

img_view_layout.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical" android:layout_width="match_parent"    android:layout_height="match_parent">     <EditText        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:id="@+id/img_layout_imgText"        android:hint="请输入地址">     </EditText>    <Button        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:text="查看"        android:onClick="imgviewonClick"></Button>    <ImageView        android:id="@+id/img_layout_img"        android:layout_width="match_parent"        android:layout_height="match_parent"></ImageView></LinearLayout>

更多相关文章

  1. Android获取移动设备的IP地址
  2. Android获取物理地址(支持5.0~10.0)
  3. Android 获取IP地址的实现方法
  4. google maps api 地址
  5. android 点击分享内容中的连接地址在应用中打开浏览
  6. Android邮件地址正则表达式
  7. Android: 用jni 获取MAC地址
  8. Android水面落叶动态壁纸源码及分析 附下载地址

随机推荐

  1. PHP 数组常用函数总结
  2. PHP重置数组为连续数字索引的三种方式
  3. PHP中箭头函数的实例详解
  4. PHP根据键值合并数组
  5. php单例模式 使用场景和使用方法
  6. 学习PHP死循环写法和作用
  7. PHP 简单实现延时操作
  8. 详细解读PHP中return用法(附代码)
  9. PHP yield 协程 生成器用法的了解
  10. Go,PHP,Swoole 并发测试详解