2

解析后,我从 Rss 文件中获取 HtmlString。我想删除所有 html 标记,并且只需要在我的表单上显示纯文本,为此我提到了 LWUIT HtmlComponent 类,我使用了以下代码:

    private void displayCompleteNewsScreen(News detailNews) {
        html.removeAll();
        form2.removeAll();
        form2.repaint();
        form2.addCommand(m_backCommand);
        form2.addCommandListener(new ActionListener() {

            public void actionPerformed(ActionEvent ae) {
                form1.show();
            }
        });
    String content= detailNews.getDescription();
    html.setPreferredSize(new Dimension(300,300));
    html.setHTML(content, null, null, false);
    form2.addComponent(html);
    form2.show();
}

我能够在我的 LWUITform 上成功显示文本,但是每次我在表单上显示我的文本时都会抛出以下异常

例外1:

Uncaught exception: java.util.NoSuchElementException
    at java.util.Vector.lastElement(Vector.java:456)
 - com.sun.lwuit.html.HTMLComponent.popContainer(HTMLComponent.java:3667)
 - com.sun.lwuit.html.HTMLComponent.processTag(HTMLComponent.java:2825)
 - com.sun.lwuit.html.HTMLComponent.rebuildPage(HTMLComponent.java:1653)
 - com.sun.lwuit.html.HTMLComponent.documentReady(HTMLComponent.java:1113)
 - com.sun.lwuit.html.HTMLComponent$1.run(HTMLComponent.java:770)

例外2:

Uncaught exception: 
  java.lang.OutOfMemoryError
   (stack trace incomplete)
java.lang.OutOfMemoryError
   (stack trace incomplete)

例外3:

Uncaught exception: java.lang.IllegalArgumentException: Component is already contained in Container: Container[x=0 y=0 width=0 height=0, layout = BoxLayout, scrollableX = false, scrollableY = false, components = [Container]]
 - com.sun.lwuit.Container.insertComponentAt(Container.java:370)
 - com.sun.lwuit.Container.addComponent(Container.java:334)
 - com.sun.lwuit.html.HTMLComponent.newLine(HTMLComponent.java:1878)
 - com.sun.lwuit.html.HTMLComponent.processTag(HTMLComponent.java:2826)
 - com.sun.lwuit.html.HTMLComponent.rebuildPage(HTMLComponent.java:1653)
 - com.sun.lwuit.html.HTMLComponent.documentReady(HTMLComponent.java:1113)

注意:我的 HtmlString 将不包含任何图像和 src 标签

谁能帮我...

4

1 回答 1

0

HTML 代码中似乎存在解析错误。它是包含实际 HTML 标签、正文等的全套 HTML 吗?

于 2012-10-24T16:56:29.883 回答