1

I have follows below xml feed:

<Categories>
 <Category name="Title 1"
 <Article>
  <article title="subtitle 1"  id="1" >
   <thumb_image>
   <image url="http://forfeed.jpeg"/></thumb_image>
    <images>
    <image url="http://ad_thumb.jpg"/>
      </images>
     </article>
  <article title="subtitle 2"  id="2" >
     <image url="http://forfeed.jpeg"/></thumb_image>
      <images>
    <image url="http://ad_thumb.jpg"/>
      </images>
    </article>
 </Article>
  </Category>
  <Category name="Title 2"
  <Articles>
  <article title="subtitle 4"  id="4" >
    <image url="http://forfeed.jpeg"/></thumb_image>
      <images>
    <image url="http://ad_thumb.jpg"/>
      </images>
    </article>
  <article title="subtitle 5"  id="5" >
  <image url="http://forfeed.jpeg"/></thumb_image>
  <images>
    <image url="http://ad_thumb.jpg"/>
      </images>
    </article>
 </Articles>
 </Category>

This is my handler class:

  public void startElement(String uri, String localName, String qName,Attributes attributes) throws SAXException {
   currentElement = true;
   if (localName.equals("Categories"))
     {
     sitesList = new SitesList();
    }
   ------------------------
     ---------------------
      ---------------------
      else if (localName.equals("thumb_image")) {
           ImageList ImageList = new ImageList();
       n++;
          isThumbURL = true;
               } 
          else if (localName.equals("image")) {
           if (isThumbURL)
          {

          String attr = attributes.getValue("url");
            sitesList.setImageURL(attr);
            String Sub_arry=n+attr;
             Appscontent.Sub_arraylist.add(Sub_arry);

                 }}}

In my main activity have to set the image :

im.setImageBitmap(Appscontent.Sub_arraylistimage);

In these line am getting following error:

The method setImageBitmap(Bitmap) in the type ImageView is not applicable for the arguments (ArrayList)

How can i resolve these error.please help me...

EDIT:

In my xml feed how can i get the image url from thumb_image tag alone...but in these code am getting the image url from both thumb_image and images tag..how can i write the condition for these...

user2098063
  • 85
  • 1
  • 1
  • 7

2 Answers2

0

This error is occuring because you are trying to set arraylist into imageview but image view wants bitmap to show so you should do like

im.setImageBitmap(Appscontent.Sub_arraylistimage.get(0));

but this will receive url of image so check out the link below to load image from url

show image from url or this url

Community
  • 1
  • 1
Abhinav Singh Maurya
  • 3,313
  • 8
  • 33
  • 51
0

You need to convert the Url of the image to the Bitmap and then set that Bitmap in your imgageView

There are many ways to load the image from the URL. Efficient way to load the images would be doing it in the background thread as if you try to load the images in UI thread then the UI thread will hang and In Android OS above 4.0 it will crash with NetworkOnMainTHread Excpetion.There are many lazy laoder approaches You can try any one of them:

1.Universal ImageLoader: https://github.com/nostra13/Android-Universal-Image-Loader

2.Fedor's Lazy loader: https://github.com/thest1/LazyList

3.http://android-developers.blogspot.in/2010/07/multithreading-for-performance.html

Karan_Rana
  • 2,813
  • 2
  • 26
  • 35