Alternative for String.join in Android?

前端 未结 3 468
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 05:19

I want to concatenate an ArrayList with commas as separators. I found this answer, stating it\'s possible to use String.join in Java.

When I try to use

相关标签:
3条回答
  • 2020-12-14 05:51

    You can use this

    TextUtils.join(", ", your_list);
    
    0 讨论(0)
  • 2020-12-14 06:03

    You can use TextUtils.join instead:

    String result = TextUtils.join(", ", list);
    

    (String.join was added in Java 8, which is why you can't use it in Android.)

    0 讨论(0)
  • 2020-12-14 06:08
    String[] List ={"<html>","<body>","<title>"};
    String abc;       
    abc =TextUtils.join("\n", List);
    textmsg.getText().insert(textmsg.getSelectionStart(), abc);
    

    result:

    <html>
    <body>
    <title>
    
    0 讨论(0)
提交回复
热议问题