我如何使我的Android应用程序前缀每个显示“&quot”的文本行?
我的应用显示这样的一长串文本:
我想添加一个”>每行的字符,所以我尝试了以下代码:
private String addPrefixChars(String text) {
StringBuilder builder = new StringBuilder();
StringTokenizer st = new StringTokenizer(text, NL);
builder.append(NL);
for (int i = 0, count = st.countTokens(); i < count; i++) {
builder.append(">").append(st.nextToken()).append(NL);
}
return builder.toString();
}
并最终以此为:
请注意,只有一个“&gt;”整个文本的字符,而我试图使每个显示的行以“&gt;”开头。有人有什么想法吗?
My app displays a long line of text like this:
I want to add a ">" character to each line, so I tried the following code:
private String addPrefixChars(String text) {
StringBuilder builder = new StringBuilder();
StringTokenizer st = new StringTokenizer(text, NL);
builder.append(NL);
for (int i = 0, count = st.countTokens(); i < count; i++) {
builder.append(">").append(st.nextToken()).append(NL);
}
return builder.toString();
}
and ended up with this:
Note that there's only one ">" character for the entire text, whereas I'm trying to make each displayed line start with ">". Anyone have any ideas how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我试图实现您的需求。
文本 :
代码添加“&gt;”在
textView
的每一行中:输出:
I've tried to achieve what you need.
Text :
Code to add ">" in each line of
TextView
:output :
我最终将包含原始文本的字段更改为文本视图,并为答复创建诚意。我不必以“&gt;”为前缀。相反,我只是将其与答复区分开来。
I ended up changing the field containing the original text to a TextView and creating an EditText for the reply. I didn't have to prefix the original with ">"; instead, I just italicized it to distinguish it from the reply.