AlertDialog.Builder setMessage 在文本中换行

AlertDialog.Builder setMessage in the text to wrap

AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(R.string.update_dialog_tittle));
    builder.setMessage(updateInfo.getDescription());
    builder.setCancelable(false);

updateinfo是javabean,是通过阅读本站XML获得的,本站XML

<?xml version="1.0" encoding="UTF-8"?><updateInfo><version>1.2</version><url>http://localhost:8080/test.apk</url><description>update\n1:test\n2:test\n3test\n4:test</description></updateInfo>

要显示的文字显示"update \n1: test \n2: test \n3 test \n4: test",\n显示,无换行效果

试试看 如果您的 XML 将 \n 替换为 <br>

<?xml version="1.0" encoding="UTF-8"><updateInfo><version>1.2</version><url>http://localhost:8080/test.apk</url><description>update<br>1:test<br>2:test<br>3:test<br>4:test</description></updateInfo></p> <br>    

你可以这样试试

builder.setMessage(Html.fromHtml(updateInfo.getDescription());