Note that there are some explanatory texts on larger screens.

plurals
  1. PODownloading many pictures from a server in android
    primarykey
    data
    text
    <p>I don't know how to get several images from a URL.</p> <p>Those images come in as Bitmap; I need to convert them to drawable, but I don't know how.</p> <blockquote> <p>Drawable icon = getResources().getDrawable(R.drawable.icon);</p> </blockquote> <p>Am I doing it correctly calling the <code>url(images)</code>, or is there a better way to do that?</p> <hr> <p><strong>This is the asynctask where I get the images</strong></p> <pre><code> private class BajarImagenTask extends AsyncTask&lt;String, Void, Bitmap&gt; { @Override protected Bitmap doInBackground(String... urls) { return BajarImagen(urls[0]); } protected void onPostExecute(Bitmap result){ Drawable icon = getResources().getDrawable(R.drawable.icon); point.setImage(d); } } </code></pre> <p>This the connection:</p> <pre><code> private Bitmap BajarImagen (String URL) { Bitmap bitmap = null; InputStream in = null; try { in=OpenHttpConnection(URL); bitmap=BitmapFactory.decodeStream(in); in.close(); } catch (IOException e1) { } return bitmap; } </code></pre> <p><strong>Here is the method with a "FOR" inside to get several URLs and calling many times the asynctask</strong></p> <pre><code> public void datosDesdeElXML(String[][] datos) { for(int i = 0; i &lt; moteles.length;i++){ String motel[] = moteles[i]; double lat = Double.valueOf(motel[0].trim()); double lng = Double.valueOf(motel[1].trim()); String name = motel[2].trim(); String address = motel[3].trim(); **String urldefotoglobo = motel[4].trim();** // here i get url from server in a xml format String aidis = motel[5].trim(); **new BajarImagenTask().execute(urldefotoglobo);** // Here i call the asynctask } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload