1

i want to display an image and Description from Rss File on LWUIT Form Screen here my Code:

HTMLComponent com=new HTMLComponent();
com.setBodyText(detailNews.getDescription());
form2.addComponent(com);

In place of *detailNews.getDescription()*,the string coming form an Rss URL in a loop is

<p><img border="1" align="left" width="150" vspace="2" hspace="2" height="159" src="/tmdbuserfiles/Prithvi2_launch1(3).jpg" alt="Prithvi II, ballistic missile, DRDO, armed forces,Chandipur, Balasore district, Odisha State" />The Strategic Forces 
Command of the armed forces successfully flight-tested the surface-to-surface Prithvi II missile from Chandipur in Balasore </P>

if i execute, i am facing the application has unexpectedly quit because ,it ran out of memory exception

String
  • 3,660
  • 10
  • 43
  • 66

1 Answers1

3

If you do not need to show the image, remove the img tag from the html string.

String description = detailNews.getDescription();
StringBuffer newDescription = new StringBuffer();
int imgIndex = description.indexOf("<img");

newDescription.append(description.substring(0, imgIndex));
imgIndex = description.indexOf(">", imgIndex + 1);
newDescription.append(description.substring(imgIndex + 1));
description = newDescription.toString();
com.setBodyText(description);
Telmo Pimentel Mota
  • 4,033
  • 16
  • 22
  • i am reading 4 Rss files and displaying on my Form with tabs, i am able to read 4 files and successfully displayed titles and images (Note:images are displayed using ListCellrenderer),but when i click on list item ,i need to display the description,but i am facing outof memory exception again and my application is getting closed? – String Aug 29 '12 at 05:22
  • You might be creating too much objects to treat the click event. But I think this is subject to another question... – Telmo Pimentel Mota Aug 29 '12 at 11:30
  • now i tested again,even i am not able to display titles also,in the middle itself,it is throwing the outofmemory exception – String Aug 29 '12 at 11:38
  • Hi,can you give your email id – String Aug 29 '12 at 11:42