How to load the image of a Url into an ImageView

-1
 rs = statement.executeQuery(query);
            List<Map<String, String>> data = null;
            data = new ArrayList<Map<String,String>>();
            while(rs.next()){
                Map<String, String> datanum = new HashMap<String, String>();
                datanum.put("A", rs.getString("Nome").trim().toString());
                datanum.put("B", "http://acme.com.br/pic/1/" + rs.getString("Al_Matricula").trim().toString() + ".jpg");  // <<<--- URL
                datanum.put("C", rs.getString("Id").trim().toString());
                datanum.put("D", rs.getString("Ean").trim().toString());
                datanum.put("E", rs.getString("Code").trim().toString());
                data.add(datanum);
            }
            String[] from = {"A", "B", "C", "D", "E"};
            int[] views = { R.id.tvNome,
                            R.id.tvTemp,   //  <<<----  preciso que meu imageview que esta dentro do listview carregue esta imagem 
                            R.id.tvId,
                            R.id.tvEan,
                            R.id.tvCode };    



        AD = new SimpleAdapter(this, data, R.layout.activity_modelo, from, views);
        lst_Alunos.setAdapter(AD);
    
asked by anonymous 17.09.2018 / 12:48

1 answer

0

Use the Glide library, follow the example of how to implement in the code:

  Glide.with(this)
                    .load(urlImages.get("SUA URL"))
                    .asBitmap()
                    .listener(new RequestListener<String, Bitmap>() {
                        @Override
                        public boolean onException(Exception e, String model, com.bumptech.glide.request.target.Target<Bitmap> target, boolean isFirstResource) {
                            // AÇÕES A SE EXECUTAR CASO HOUVER ERRO
                            return false;
                        }

                        @Override
                        public boolean onResourceReady(Bitmap resource, String model, com.bumptech.glide.request.target.Target<Bitmap> target, boolean isFromMemoryCache, boolean isFirstResource) {
                            // AÇÕES A SE EXECUTAR QUANDO FOR CARREGADA A IMAGEM
                            return false;
                        }
                    }).into(SUA IMAGEVIEW);
    
17.09.2018 / 17:30