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根据包名获取签名MD5信息
  2. android 开源自组织网络开源包
  3. Android获取移动设备的IP地址
  4. android 內存等使用情況
  5. Android学习视频
  6. Android图片缓存加强版(LruCache+DiskLruCache+软引用)
  7. Android获取物理地址(支持5.0~10.0)
  8. 【实战】android网页源代码查看器
  9. lyricView--歌词显示控件

随机推荐

  1. Android系统启动流程(1) —— 解析init进
  2. java.lang.NoClassDefFoundError: com.go
  3. 打造android ORM框架opendroid(五)——数
  4. **Android** 基础(一)
  5. speex编解码在android上实现
  6. android学生管理系统,利用linerLayout,实现
  7. Android集成友盟QQ、空间分享、微信、微
  8. 唤醒锁: 检测 Android* 应用中的 No-Slee
  9. Jackson 高性能的JSON处理 android/移动
  10. 谷歌借Android布局中国3G