1

我想在我的代码中在 LWUIT 表单屏幕上显示来自 Rss 文件的图像和描述:

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

代替* detailNews.getDescription() *,在循环中形成 Rss URL 的字符串是

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

如果我执行,我将面临应用程序意外退出,因为它内存不足异常

4

1 回答 1

3

如果您不需要显示图像,请img从 html 字符串中删除标记。

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);
于 2012-08-28T11:59:38.570 回答