0
我在服务器url中有图像,然后我传递并显示在卡片上。我已经在Android中使用LoaderImageView库完成了这个工作,并在Glass中显示,我将url链接传递给卡片。但我得到这个错误 “在类型CardBuilder的方法addImage(绘制对象)不适用的参数(字符串)”如何显示来自url的图像
代码:
public static Drawable drawableFromUrl(String url) {
Bitmap x;
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.connect();
InputStream input = connection.getInputStream();
x = BitmapFactory.decodeStream(input);
return new BitmapDrawable(x);
} catch(MalformedURLException e) {
//Do something with the exception.
}
catch(IOException ex) {
ex.printStackTrace();
}
return null;
}
View view = new CardBuilder(getBaseContext(), CardBuilder.Layout.TITLE)
.setText("TITLE Card")
// .setIcon(R.drawable.ic_phone)
.addImage(drawableFromUrl(link))
.getView();
获取未处理的异常类型IOException错误 – karthees 2014-11-09 15:22:50
请检查我编辑的代码。仍然不工作.. – karthees 2014-11-09 15:30:29
你可以查看我的编辑或查看GitHub上的完整示例。 – pt2121 2014-11-10 01:11:13