我试图从url加载图像到我的android ImageView。但它没有给我的网址形象。但是当我打电话另一个样本网址加载在ImageView的URL图像将不会设置为ImageView Android
我的URL这给空
https://192.168.100.15/HeyVoteWeb/Home/GetImage/d9cbd32c-47fc-4644-ab97-1f525c96e9ed/100000102
此示例网址为我的作品
https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png
这是我的代码我正致力于
public class GetImage extends Activity{
ImageView postpic1;
Bitmap b;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.all_posts);
postpic1 = (ImageView) findViewById(R.id.postpic1);
information info = new information();
info.execute("");
}
public class information extends AsyncTask<String, String, String>
{
@Override
protected String doInBackground(String... arg0) {
try
{
URL url = new URL("https://localhost/HeyVoteWeb/Home/GetImage/d9cbd32c-47fc-4644-ab97-1f525c96e9ed/100000102");
InputStream is = new BufferedInputStream(url.openStream());
b = BitmapFactory.decodeStream(is);
} catch(Exception e){}
return null;
}
@Override
protected void onPostExecute(String result) {
postpic1.setImageBitmap(b);
}
}
}
这是URL '的https:// 192.168.100.15/HeyVoteWeb /主页/的getImage/d9cbd32c-47fc-4644-ab97-1f525c96e9ed/100000102' – Naz141
是的,我看到了。这是对本地HTTPS网络服务器的调用,那么你有一个运行?如果没有,这个URL永远不会给你一张图片。这将调用您正在运行此操作的计算机/设备,而不是**网络上的随机图像(仅供说明)。 – LilaQ
yes在您的浏览器中运行该网址 – Naz141