在j2me中处理文本html [英] handle text html in j2me
问题描述
当我进入细节时,正文文本显示html标记。
这是我的照片申请:
我没有想要显示html标签。
这是我的代码,显示详细信息页面:
private void detailScreen(News news){
Form form = new Form(news.getTitle());
StringItem detail = new StringItem(,news.getBody()。toString());
mBackCommand = new Command(Back,Command.BACK,0);
form.append(detail);
form.addCommand(mBackCommand);
form.setCommandListener(this);
// Canvas c = new MyCanvas(this,news);
mDisplay.setCurrent(form);
}
请有人告诉我我在这里做错了什么?
使用 jsoup 使用它: 如果你有这个库,你的代码现在可以写成: 更新 其他解析器选项: http://jericho.htmlparser.net/docs/index.html 但即使在这种情况下,完整的库可能无法编译,您可能需要提取所需的类。这在使用j2me时总是如此。 这也许是有用的: http://www.j2mehtml.com/j2mehtml/index.htm I tried to make application RSS news, and it can give detail news to user. When I go to detail, the body text is show the html tag. This is picture of my application: I don't want to show html tags. This is my code to show detail page: Please can someone tell me what's I'm doing wrong here? Its quite simple to do with jsoup using it: if you have that library your code can now be written as:
UPDATE Other parser options: http://jericho.htmlparser.net/docs/index.html
http://jericho.htmlparser.net/docs/javadoc/net/htmlparser/jericho/TextExtractor.html But even in this case complete library may not compile and you may have to extract the classes you need. This is always the case when working with j2me. Also this might be useful: http://www.j2mehtml.com/j2mehtml/index.htm 这篇关于在j2me中处理文本html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
Jsoup.parse(htmlText ).text()
private void detailScreen(News news){
Form form = new Form(news.getTitle());
StringItem detail = new StringItem(,Jsoup.parse(news.getBody()。toString())。text());
mBackCommand = new Command(Back,Command.BACK,0);
form.append(detail);
form.addCommand(mBackCommand);
form.setCommandListener(this);
// Canvas c = new MyCanvas(this,news);
mDisplay.setCurrent(form);
}
http://jericho.htmlparser.net/docs/javadoc/net/htmlparser/jericho/TextExtractor.html
private void detailScreen(News news){
Form form = new Form(news.getTitle());
StringItem detail = new StringItem("", news.getBody().toString());
mBackCommand = new Command("Back", Command.BACK, 0);
form.append(detail);
form.addCommand(mBackCommand);
form.setCommandListener(this);
//Canvas c = new MyCanvas(this, news);
mDisplay.setCurrent(form);
}
Jsoup.parse(htmlText).text()
private void detailScreen(News news){
Form form = new Form(news.getTitle());
StringItem detail = new StringItem("",Jsoup.parse(news.getBody().toString()).text());
mBackCommand = new Command("Back", Command.BACK, 0);
form.append(detail);
form.addCommand(mBackCommand);
form.setCommandListener(this);
//Canvas c = new MyCanvas(this, news);
mDisplay.setCurrent(form);
}