String
String

Reputation: 3728

LWUIT HtmlComponent out of memory exception

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

Upvotes: 1

Views: 238

Answers (1)

Telmo Pimentel Mota
Telmo Pimentel Mota

Reputation: 4043

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);

Upvotes: 3

Related Questions