• 大小: 1.29M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-01-22
  • 语言: Java
  • 标签: 图片  网络  

资源简介

【实例简介】简单的网络图片查看

【核心代码】public void visit(View view) {
et_imageAdress = (EditText) findViewById(R.id.et_imageAdress);
final String imagetAdress = et_imageAdress.getText().toString();
imageView = (ImageView) findViewById(R.id.imageView);
if(TextUtils.isEmpty(imagetAdress)) {
Toast.makeText(this, "访问路径不能为空!", 0).show();
} else {
new Thread(){
public void run() {
try {
URL url = new URL(imagetAdress);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(5000);
if(conn.getResponseCode()==200) {
InputStream is = conn.getInputStream();
Bitmap bitmap= BitmapFactory.decodeStream(is);
//imageView.setImageBitmap(bitmap);
Message msg = Message.obtain();
msg.what = IMAGE_VIEW;
msg.obj = bitmap;
Log.i(Tag, "消息接收到了1。。。");
handler.sendMessage(msg);
}else {
Message msg = Message.obtain();
msg.what = OHTER_ERROR;
handler.sendMessage(msg);
//Toast.makeText(MainActivity.this, "123!", 0).show();
}
} catch (MalformedURLException e) {
//Toast.makeText(MainActivity.this, "访问路径错误!", 0).show();
Message msg = Message.obtain();
msg.what = PATH_ERROR;
handler.sendMessage(msg);
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
//Toast.makeText(MainActivity.this, "访问网络失败!", 0).show();
Message msg = Message.obtain();
msg.what = INTERNET_ERROR;
handler.sendMessage(msg);
e.printStackTrace();
}
}
}.start();
}
}

资源截图

代码片段和文件信息

/** Automatically generated file. DO NOT MODIFY */
package com.ItYexu.InternetImagetView;

public final class BuildConfig {
    public final static boolean DEBUG = true;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-02-22 23:19  网络图片查看器\
     文件         475  2016-11-16 10:16  网络图片查看器\.classpath
     文件         857  2015-08-31 08:56  网络图片查看器\.project
     目录           0  2016-02-22 23:19  网络图片查看器\.settings\
     文件         177  2015-08-31 08:56  网络图片查看器\.settings\org.eclipse.jdt.core.prefs
     文件         966  2015-08-31 11:39  网络图片查看器\AndroidManifest.xml
     目录           0  2016-12-14 11:46  网络图片查看器\assets\
     目录           0  2016-12-14 11:44  网络图片查看器\bin\
     文件         966  2016-11-16 10:16  网络图片查看器\bin\AndroidManifest.xml
     目录           0  2016-11-16 10:16  网络图片查看器\bin\classes\
     目录           0  2016-11-16 10:16  网络图片查看器\bin\classes\com\
     目录           0  2016-11-16 10:16  网络图片查看器\bin\classes\com\ItYexu\
     目录           0  2016-11-16 10:16  网络图片查看器\bin\classes\com\ItYexu\InternetImagetView\
     文件         367  2016-11-16 10:16  网络图片查看器\bin\classes\com\ItYexu\InternetImagetView\BuildConfig.class
     文件        1680  2016-11-16 10:16  网络图片查看器\bin\classes\com\ItYexu\InternetImagetView\MainActivity$1.class
     文件        2289  2016-11-16 10:16  网络图片查看器\bin\classes\com\ItYexu\InternetImagetView\MainActivity$2.class
     文件        2188  2016-11-16 10:16  网络图片查看器\bin\classes\com\ItYexu\InternetImagetView\MainActivity.class
     文件         373  2016-12-14 08:51  网络图片查看器\bin\classes\com\ItYexu\InternetImagetView\R$attr.class
     文件         494  2016-12-14 08:51  网络图片查看器\bin\classes\com\ItYexu\InternetImagetView\R$dimen.class
     文件         440  2016-12-14 08:51  网络图片查看器\bin\classes\com\ItYexu\InternetImagetView\R$drawable.class
     文件         497  2016-12-14 08:51  网络图片查看器\bin\classes\com\ItYexu\InternetImagetView\R$id.class
     文件         436  2016-12-14 08:51  网络图片查看器\bin\classes\com\ItYexu\InternetImagetView\R$layout.class
     文件         421  2016-12-14 08:51  网络图片查看器\bin\classes\com\ItYexu\InternetImagetView\R$menu.class
     文件         505  2016-12-14 08:51  网络图片查看器\bin\classes\com\ItYexu\InternetImagetView\R$string.class
     文件         464  2016-12-14 08:51  网络图片查看器\bin\classes\com\ItYexu\InternetImagetView\R$style.class
     文件         783  2016-12-14 08:51  网络图片查看器\bin\classes\com\ItYexu\InternetImagetView\R.class
     文件      625116  2016-12-14 08:51  网络图片查看器\bin\classes.dex
     目录           0  2016-11-16 10:16  网络图片查看器\bin\dexedLibs\
     文件      211326  2016-11-16 10:16  网络图片查看器\bin\dexedLibs\android-support-v4-3f02310de0e88163ef7eeb7972ff1117.jar
     文件         120  2016-12-14 08:50  网络图片查看器\bin\jarlist.cache
     目录           0  2016-11-16 10:16  网络图片查看器\bin\res\
............此处省略53个文件信息

评论

共有 条评论