如何将文本拆分为android textview

如何将文本拆分为android textview,android,textview,Android,Textview,如何通过split()或matcher将文本拆分为android textview。当我分割文本时,我想保留它。我用过 Pattern stuff = Pattern.compile("[\\s]|[\\w+]"); 及 split((?我想你想把文本分成句子,如下所示 Lorem Ipsum is simply dummy text of the printing and typesetting industry Lorem Ipsum has been the industry's st

如何通过split()或matcher将文本拆分为android textview。当我分割文本时,我想保留它。我用过

 Pattern stuff = Pattern.compile("[\\s]|[\\w+]");


split((?我想你想把文本分成句子,如下所示

Lorem Ipsum is simply
dummy text of the printing and typesetting industry
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged
It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
我使用了字符串的拆分函数,如下所示

String[] results = source.split("!|\\.|\\?");
希望能有帮助

另外,如果您想保留分隔符,下面是示例

    String[] results = source.split("!|\\.|\\?");

    int offset = 0;
    for(String result : results){

        offset += result.length();
        // just append the delimiter after the split sub string.
        Log.d("", "result = " + result + source.charAt(offset));
        offset +=1;
    }

发布一个您试图拆分的文本示例。@Elenasys的问题是编辑确定您的文本中的分隔符是什么?空格“.”?@Elenasys我不知道textview如何将文本拆分为单词/句子,我不知道哪些分隔符是这样的。我想它应该是空格(必须支持多个空格),“-”,“,”,“.我也想保留delimeters我也想保留delimeters
    String[] results = source.split("!|\\.|\\?");

    int offset = 0;
    for(String result : results){

        offset += result.length();
        // just append the delimiter after the split sub string.
        Log.d("", "result = " + result + source.charAt(offset));
        offset +=1;
    }