我有一个Html字符串:
String html="<p><img border=\"1\" align=\"left\" width=\"150\" vspace=\"2\" hspace=\"2\" height=\"159\" src=/"tmdbuserfiles/ntr-vv-vinayak-pics.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>";我想在我的LWUIT表单屏幕上显示文本和图像,为了满足我的要求,我使用了以下代码:
public class LwuitMidlet extends MIDlet {
public void startApp() {
Display.init(this);
Form f = new Form("Hello, LWUIT!");
String html="<p><img border=\"1\" align=\"left\" width=\"150\" vspace=\"2\" hspace=\"2\" height=\"159\" src=www.teluguone.com/tmdbuserfiles/ntr-vv-vinayak-pics.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>";
HTMLComponent com=new HTMLComponent();
com.setPreferredSize(new Dimension(300,300));
com.setHTML(html, null, null, false);
com.setShowImages(true);
//com.setHTML(image, null, null, false);
f.addComponent(com);
f.show();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}如果我使用上述代码,我只能显示文本,但不能显示图像,我已经在NokiaSDK2.O和SDK3.0.5上测试了我的应用程序
有人能帮我吗?
发布于 2012-10-24 16:58:37
您需要完整的HTML代码,而不仅仅是一个片段。HTML、主体等。
发布于 2012-10-13 18:55:02
img标记上的src属性在开始时缺少(")字符。我没有尝试,但这可能是它。
发布于 2013-10-25 09:49:20
你试过用
com.setBodyText(html);相反,
com.setHTML(html, null, null, false);和。我正在使用来自LWUIT示例应用程序的HttpRequestHandler实现(您可以获得示例应用程序: LWUITBrowser),而不是DefaultRequestHandler或null。
HttpRequestHandler handler = new HttpRequestHandler();
HTMLComponent com = new HTMLComponent(handler);希望能帮上忙。
https://stackoverflow.com/questions/12871421
复制相似问题