android -\n 出现在字符串中不起作用

标签 android database string

获取数据库字符串时:

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/

相关文章:

c - 如何在C中的数组中存储字符串和整数

string - 检查 clojure 中的字符串是否包含子字符串

android - 如何在 Android 中使用加速度计值移动图像

android - 删除旧的 Gradle 版本是否安全?

java - 需要方法建议 : Database insert from 1 db to another

ruby-on-rails - 如何将对象 `id` 存储在迁移文件中?

python - 将作为另一个列表元素的列表元素从字符串转换为整数

android - 防止 fragment 自定义动画在屏幕旋转时播放?

android - 从 fragment 到 Activity 问题的接口(interface)通信

database - 我可以设置和获取对象的托管 JSON 数据库