如何在Android上获得多线警报标题

use*_*184 3 android android-alertdialog

有没有办法获得超过警报标题的2行AlertDialog

我只找到"创建自定义对话框"作为可能的解决方案.

然而,理想情况下,人们可以设置attribute- 但我找不到任何.

编辑:

AlertDialog alertDialog = new AlertDialog.Builder(AlertAndCallUtility.this).create();
alertDialog.setTitle(getString(R.string.alert_title));
alertDialog.setMessage(getString(R.string.alert_msg));
alertDialog.setButton(getString(R.string.alert_OK),
    new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            finish();
        }});
alertDialog.setIcon(R.drawable.icon);
alertDialog.show();
Run Code Online (Sandbox Code Playgroud)

和xml

<string name="alert_OK">OK:</string>
<string name="alert_title">Please correct your input, parameters are missing.</string>
<string name="alert_msg">Please enter them in the EXTRA tab.</string>
Run Code Online (Sandbox Code Playgroud)

如上所述,在"..missing"之前插入\n,只需将其剪掉,只有前两行才能看到标题的"是".

Yoj*_*mbo 7

您需要使用AlertDialog.Builder().setCustomTitle():

AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
TextView textView = new TextView(context);
textView.setText("your very long title here");
dialogBuilder.setCustomTitle(textView);
Run Code Online (Sandbox Code Playgroud)