我想在LWUIT表格屏幕上显示来自Rss文件的图像和描述 在这里我的代码:
HTMLComponent com=new HTMLComponent();
com.setBodyText(detailNews.getDescription());
form2.addComponent(com);
代替 * detailNews.getDescription() *,循环中来自Rss网址的字符串是
<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>
如果我执行,我面临的应用程序意外退出,因为它耗尽了内存异常
答案 0 :(得分:3)
如果您不需要显示图片,请从html字符串中删除img
标记。
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);