0

I have a xml file that contains an url which is an Image, accessable via Amazon. I want to show that Image in ´ImageView. I know to download the image I need to use aAsyncTask`. But I think this is to use when I have an url, but in my case I get this url from xml file.

this is my xml:

 <?xml version="1.0" encoding="UTF-8"?>
<Items>
<Item>
    <DetailPageURL>
        https://www.amazon.de/Chemie-76128-Felgenreiniger-Alu-Teufel-Spezial/dp/B004LAXG9C?psc=1**&**SubscriptionId=mykey**&**tag=mytag&linkCode=xm2**&**camp=2025&
        creative=165953**&**creativeASIN=B004LAXG9C
    </DetailPageURL>
    <URL>https://images-eu.ssl-images-amazon.com/images/I/412-16OaNFL._SL160_.jpg</URL>
    <Feature>Der neue "Alu-Teufel-Spezial"" ist ein moderner Hochleistungs-Felgenreiniger. Die
        neue, säurefreie Rezeptur ermöglicht die problemlose Reinigung von Stahl- und
        Aluminiumfelgen sowie Radkappen.
    </Feature>
    <FormattedPrice>EUR 13,50</FormattedPrice>
    <Title>Tuga Chemie 76128 Felgenreiniger Alu-Teufel Spezial</Title>

</Item>
</Items>

The image url is in the <URL> element. How can I extract this url and load this Image to ImageView

This is only an example. Actually in this xml file there are nearly 20 Items, so 20 specific images. So putting the url to strings.xml or something like that won't work since it would take too much time.

EDIT: I parsed the xml, and it works fine. But I have no idea how to load images.

Blnpwr
  • 1,793
  • 4
  • 22
  • 43

2 Answers2

1

First of all, check how to read xml files

Secondly, get your image URL, then check how to display an image from the network using Picasso or glide

Mohammed Mahmoud
  • 1,138
  • 10
  • 14
1

If you already have a image url you can use image loading libraries like Picasso or Glide

These libraries handle everything from image downloading, caching, placeholders, error images and much more.

EDIT1:

Libraries like Picasso or Glide, are responsible for controlling the asynchronous process, optimizing and avoiding errors with the UI thread.

drilonrecica
  • 327
  • 1
  • 4
  • 19