Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在警报窗口中格式化文本_Android_Android Alertdialog - Fatal编程技术网

Android 在警报窗口中格式化文本

Android 在警报窗口中格式化文本,android,android-alertdialog,Android,Android Alertdialog,伙计们,我有一篇这样的文章: A: hi how are you. B: I am fine thank you. A: how is your mother. B: she is fine. 我希望以相同的方式显示在警报窗口中,与文本长度无关。下面是我的警报窗口代码 AlertDialog.Builder bu = new AlertDialog.Builder(this); bu.setMessage(""+((Node) textFNListU.item(0)).getNodeValue

伙计们,我有一篇这样的文章:

A: hi how are you.
B: I am fine thank you.
A: how is your mother.
B: she is fine.
我希望以相同的方式显示在警报窗口中,与文本长度无关。下面是我的警报窗口代码

AlertDialog.Builder bu = new AlertDialog.Builder(this);
bu.setMessage(""+((Node) textFNListU.item(0)).getNodeValue().trim());
bu.setCancelable(true);
bu.setPositiveButton("OK",new DialogInterface.OnClickListener() {
            @Override
                public void onClick(DialogInterface dialog, int id) {
                // TODO Auto-generated method stub
                                dialog.cancel();
                            }
                        });
                bu.create().show();



+((Node) textFNListU.item(0)).getNodeValue().trim() ->this value i am fecthing from xml.
如何做到这一点

试试这个:

bu.setMessage(""+((Node) textFNListU.item(0)).getNodeValue().trim().replace(".",".\n"));

您现在是如何获得警报窗口的?所有文本是否都在一行中?是的,vikram它的所有内容都在一行中使用html来执行此操作没有\n@SergeyBenner链接中的代码在哪里…@Goofy你读了吗?这里有fromHtml()和setText()的例子,感谢它们的工作,但在某些方面我有?(问号)例如:你好吗?怎么做呢?正确的方法是将数据转换成html格式,并使用html.fromHtml(“此处的html”);目前:。替换(“.”,“\n”)。替换(“?”,“?\n”)