How to read a file into textview with proper displaying as like in text file?
I can able to read the file into textview.
But displaying as like in the Text file.
My Original Text File:
Testing this 1
Satheeshisdf sdf asdfsdfasd fasdfsdfsd
i can able to do it.
Trying it thats all.`
But displaying like this:
i can able to do it.
Trying it thats all.`
Layout:
<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"
/>
Program:
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:
But now i can not able to read large file(50KB).
Small file loading well.
You’re only appending every other line because you are reading two lines at a time…
Use…