android在通知中嵌入换行符 [英] android embed newline in a notification
问题描述
我需要在通知中嵌入换行符.我有两行不同的数据,我需要嵌入一个换行符来区分这两者.我修改了反斜杠-n,但这不起作用.
I need to embed a newline in a notification. I have two lines of data that are different and I need to embed a newline to distinguish between the two. I trued a backslash-n, but that does not work.
有没有办法做到这一点?
Is there a way to do this?
推荐答案
据我所知,除了创建自定义 Notification
布局之外,没有其他方法可以做到这一点.Notification
文档有执行此操作的分步过程,并且非常详尽.这里是链接.
As far as I know there is no way to do this other than creating a custom Notification
layout. The Notification
documentation has a step-by-step process on doing this and is quite thorough. Here is the link to that.
根据需要创建两行只是意味着在布局 XML 中添加一个额外的 TextView
.然后您只需将每个 TextView
的文本设置为您的两行数据,如示例所示.
Creating the two lines as you require would just mean putting in an extra TextView
in the layout XML. Then you would just set each TextView
's text to your two lines of data, as the example shows.
这篇关于android在通知中嵌入换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!