【发布时间】:2013-01-23 15:57:11
【问题描述】:
为什么在 .txt 中使用 \n 时我的输入流字符串不换行???
我正在尝试阅读,然后将其发布到 TextView 中,但它显示 \n insted to go to new line -.- 足够接近
try {
reader = new InputStreamReader(getAssets().open("koce_podatki.txt"),"UTF-8");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BufferedReader br = new BufferedReader(reader);
for(int i=-1;i<position;i++){
try {
temp = "" + br.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}}
try {
reader.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
temp=temp.replaceAll("\n", "\n");
nov = temp.split("\\|");
for(int i=0;i<23;i++){
podatek.add(""+nov[i]);
}
【问题讨论】:
-
你在 TextView.setText() 中使用 Html.fromHTML() 吗?
-
不,如果会更好,如何???
-
以您的输入文件为例。你输入的字面意思是
\n,还是你的意思是“换行符”? -
slika|Aljažev dom v Vratih|1015 m |4 月\nMaj\nJunij\nJulij\nAvgust\n9 月\nOktober |Julijske alpe ...
-
你的TextView的
MAX LINES有什么用??
标签: java android textview newline