1

画像リンクを取得するための http リクエストの作成方法: http://vec03.maps.yandex.ru/tiles?l=map&v=2.20.0&x=19783&y=10320&z=15 に ImageView を追加できるようにする

助けてください、私はウェブ開発が得意ではありません。

4

2 に答える 2

9
String imageUrl= "http://vec03.maps.yandex.ru/tiles?l=map&v=2.20.0&x=19783&y=10320&z=15";
URL url = new URL(imageUrl);
HttpURLConnection connection  = (HttpURLConnection) url.openConnection();

InputStream is = connection.getInputStream();
Bitmap img = BitmapFactory.decodeStream(is);  

imageView.setImageBitmap(img );

SOで問題を質問する前にGoogleで検索し、重複した質問を避けてください

于 2012-08-14T10:19:05.673 に答える
0
public void setImage()
    {
     ImageView icon=(ImageView)v.findViewById(R.id.icon);


                                   Drawable image = ImageOperations(getapplicationContext(), "yuour url",
                                     "image.jpg");


                                   icon.setImageDrawable(image);
    }
private Drawable ImageOperations(Context ctx, String url,
               String saveFilename) {
              try {
               InputStream is = (InputStream) this.fetch(url);
               Drawable d = Drawable.createFromStream(is, "src");
               return d;
              } catch (MalformedURLException e) {
               e.printStackTrace();
               return null;
              } catch (IOException e) {
               e.printStackTrace();
               return null;
              }
    }
              public Object fetch(String address) throws MalformedURLException,
               IOException {
              URL url = new URL(address);
              Object content = url.getContent();
              return content;
             }
于 2012-08-14T10:22:36.360 に答える