【梅开二度】调用java在图像控件中显示网络图片

administrator   ·   发表于 2个月前   ·   IAPP
首先打开iapp,然后开始操作。


新建webpic.mjava

代码:

import android.graphics.drawable.BitmapDrawable;

import java.net.HttpURLConnection;

import java.net.URL;

import java.io.InputStream;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;



public static BitmapDrawable get(String url){

BitmapDrawable pic = null;

try{

URL u = new URL(url);

HttpURLConnection conn = (HttpURLConnection) u.openConnection();

conn.setRequestMethod(”GET”);

conn.setConnectTimeout(5000);

conn.setReadTimeout(5000);

InputStream is = conn.getInputStream();

Bitmap bmp = BitmapFactory.decodeStream(is);

pic = new BitmapDrawable(bmp);

is.close();

conn.disconnect();

}catch(Exception e){}

return pic;

}
iyu调用

代码:

t(){

s id=图像控件id

s img_url=”网络图片地址,双引号不能少”

call(img,”mjava”,”webpic.get”,img_url)

ufnsui(){

us(id, ”src”, img)

}

}
2 Reply   |  Until 2个月前 | 2714 View

空心人、
发表于 2个月前

不行!!!!

评论列表

  • 加载数据中...

编写评论内容

inkxx888
发表于 2个月前

MJavaErr:
Sourced file: inline evaluation of: `` import android.graphics.drawable.BitmapDrawable; import java.net.HttpURLConnec . . . '' Token Parsing Error: Lexical error at line 26, column 23. Encountered: "u201d" (8221), after : "":

提示这个

评论列表

  • 加载数据中...

编写评论内容
LoginCan Publish Content