在警报对话框中显示多行文本

在警报对话框中显示多行文本

本文介绍了在警报对话框中显示多行文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在警报对话框中显示多行消息,而不只是一个段落.

I need to display multiple lines of messages, rather than just one paragraph, in an alert dialogue.

new AlertDialog.Builder(this)
.setTitle("Place")
.setMessage("Go there" +
        "Go here")
.setNeutralButton("Go Back", null)
.show();

是否有一种从新行开始的方法?就像在Microsoft Word中的句子后面按Enter键一样?

Is there a way to start at new lines? Just like hitting enter after a sentence in Microsoft Word?

推荐答案

对此不做任何保证,但是通常要做多行,您可以执行以下操作:

No guarantees on this, but usually to do multiple lines you do something like:

.setMessage("Go there\nGo here");

"\ n"是转义字符,表示"New Line",我不知道您的具体情况,但是您可以在几乎所有AFAIK中使用它.

The "\n" is an escape character that means "New Line" I don't know about your specific case, but you can use it in just about everything AFAIK.

这篇关于在警报对话框中显示多行文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 17:31