嗨,我希望逐句显示文本视图中的文本

时间:2015-11-16 06:50:27

标签: android string textview

我有一个字符串,其中包含产品详细信息作为段落,它来自我的网络服务。所以我想逐句地用子弹显示这些段落。例如

我的回答是那样的

{"Product":"Dell XPS 13","Image":"http://dri1.img.digitalrivercontent.net/Storefront/Company/msintl/images/English/en-INTL-Dell-XPS-13-9343-2773SLV-i7-256GB-Silver-Androidized-CWF-01967/en-INTL-L-Dell-XPS-13-9343-2773SLV-i7-256GB-Silver-Androidized-CWF-01967-mnco.jpg","Description":"The XPS 13 isn't just the smallest 33cm (13) laptop on the planet1, it also has a virtually borderless infinity display.,Its Size 32 inch","Price":"68000","Quantity":"6"} 

从我将Description转到字符串然后我想在我的展示活动页面中显示它,如下所示

.The XPS 13 isn't just the smallest 33cm (13) laptop on the planet1.

.it also has a virtually borderless infinity display.

.Its Size 32 inch

1 个答案:

答案 0 :(得分:0)

请尝试如下:

String sentence;
String text = "The XPS 13 isn't just the smallest 33cm (13) laptop on the planet1, it also has a virtually borderless infinity display.";
BreakIterator bi = BreakIterator.getSentenceInstance();
bi.setText(text);
int index = 0;
while (bi.next() != BreakIterator.DONE) {
    sentence = text.substring(index, bi.current());
    System.out.println("Your"+"    ." + sentence);
    index = bi.current();
}