Skip to content Skip to sidebar Skip to footer

Xmlpullparser Cuts The Last Element Of Bitmap

I am parsing XML file and getting error with information in listview. There is the following working code of XML parser: private Bitmap myBitmap; private List

Solution 1:

The issue is that AsynsForBitmap is not finishing the job while you are reading the next item and myBitmap will be overlapped with the next image.

Try to do it like this (Assuming displayname comes before iconsrc and SomeItem class has a method called getIcon())

case XmlPullParser.START_TAG:
           tagname = parser.getName();
           if (parser.getName().equals(iconsrc)){
               iconsrcVALUE = parser.getAttributeValue(null, "src");
               SomeItem item = new SomeItem(displaynameValue, myBitmap);
               item.setName(displaynameValue);
               item.add(item);

               item.getIcon() = new AsyncForBitmap().execute(iconsrcVALUE).get();
           }

           if (parser.getName().equals(displayname)) {           
               displaynameValue = parser.nextText();

           }
           break;

Post a Comment for "Xmlpullparser Cuts The Last Element Of Bitmap"