gpt4 book ai didi

android - AlertDialog.Builder setMessage 在文本中换行

转载 作者:行者123 更新时间:2023-11-30 02:15:34 25 4
gpt4 key购买 nike

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>

显示的文字显示“更新\n1:测试\n2:测试\n3测试\n4:测试”,\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());

关于android - AlertDialog.Builder setMessage 在文本中换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29425251/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com