Как прочитать файл в textview с правильным отображением, как в текстовом файле?Я могу прочитать файл в 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: Но теперь я не могу прочитать большой файл (50 КБ).Небольшая загрузка файла хорошо.