1
如何在文本視圖中將文件讀取爲文本文件中的正確顯示? 我可以將文件讀入textview。 但顯示在文本文件中。 我原來的文本文件:如何在文本視圖中將文件讀取爲文本文件中的正確顯示?
Testing this 1
Satheeshisdf sdf asdfsdfasd fasdfsdfsd
i can able to do it.
Trying it thats all.`
但是顯示是這樣的:
i can able to do it.
Trying it thats all.`
佈局:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:layout_weight="1.0">
<TextView
android:id="@+id/subtitletv"
android:textSize="18dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
計劃:
subtitletv = (TextView)findViewById("R.id.t");
try {
FileReader fr=new FileReader(selectedfile);
BufferedReader br=new BufferedReader(fr);
String line = null;
try {
while(br.readLine()!=null)
{
line =br.readLine();
subtitletv.append(line);
subtitletv.append("\n");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
UPDATE1: 但現在我無法讀取大文件(50KB)。 小文件加載好。
感謝的人。它正在工作。但現在我無法讀取大文件(30KB)。該怎麼辦。 – 2011-12-20 00:11:07
什麼是錯誤? – 2011-12-20 00:20:18
活動未響應。用兩個按鈕等待並確定 – 2011-12-20 00:23:07