我的服务器上有一张图片。该图像的URL是这样的: http://www.mydomain.com/123456uploaded_image.jpg使用URL设置ImageView
我想将此图像设置为我的ImageView。这里是我试过的代码:
try{
String url1 = myeventimagearray[position];
URL ulrn = new URL(url1);
HttpURLConnection con = (HttpURLConnection)ulrn.openConnection();
InputStream is = (InputStream) con.getInputStream();
Bitmap bmp = BitmapFactory.decodeStream(is);
if (null != bmp)
iveventimg.setImageBitmap(bmp);
else
Log.i("Image","Not set");
} catch(Exception e) {
e.printStackTrace();
}
当我尝试这一点,我的ImageView是空的,也就是说,它不设置图像视图和我得到了我的logcat这个系统错误:
java.lang.ClassCastException:libcore.net.http.FixedLengthInputStream不能转换到com.example.eventnotifier.Base64 $ InputStream的
Base46.java是我从网上得知编码找到的文件和解码并来自Base64符号。
任何想法,为什么我得到这个System.error?
谢谢
非常感谢!它的工作:) – Nemin 2013-05-05 21:29:12
干杯..快乐编码:) – 2013-05-05 21:42:49