获取数据库字符串时:
inf = c.getstring(5);
//inf is equals "Hello how are you?\nFine and you\nI am fine, thanks.";
我打印的时候也是这样出现,不执行参数“\n”:
tV1.setText(inf);
//the text "is Hello how are you?\nFine and you\nI am fine, thanks."
但我想要:
"Hello how are you?
Fine and you
I am fine, thanks."
问题是什么?
我的解决方案:
String finalInf = inf.replace("\\n", System.getProperty("line.separator"));
tV1.setText(finalInf);
谢谢:Skaard-Solo 和休息。
最佳答案
有一个内置的行分隔符
String newLine = System.getProperty("line.separator");
关于android -\n 出现在字符串中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18104983/