Textview break lines

0

My code opens a txt file from the net and places it in a textview. The problem is that it joins all the lines. How do I break the lines?

Another question is how to delete the tags from the text file and not break the rtmp and rtmpe links. since with http there is no problem converting to link

package com.tvmix.read; 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView; 

   public class ReadFileAssetsActivity extends Activity {
    TextView textMsg;
    final String textSource = "https://dl.dropboxusercontent.com/s/w7ga6shmocr23x4/Eventos.txt?dl=0"; 
    @Override public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        textMsg = (TextView) findViewById(R.id.textmsg);
        URL textUrl;
        try {
            textUrl = new URL(textSource);
            BufferedReader bufferReader = new BufferedReader(new InputStreamReader(textUrl.openStream()));
            String StringBuffer;
            String stringText = "";
            while ((StringBuffer = bufferReader.readLine()) != null) {
                stringText += StringBuffer;
            }
            bufferReader.close();
            textMsg.setText(stringText);
        } catch (MalformedURLException e) {
            e.printStackTrace();
            textMsg.setText(e.toString());
        } catch (IOException e) {
            e.printStackTrace();
            textMsg.setText(e.toString());
        }
    }
    
asked by anonymous 18.04.2015 / 16:28

3 answers

0

You have not concatenated the line break character ( \n ) with each line you read.

Your read loop would read:

while ((StringBuffer = bufferReader.readLine()) != null) {
    stringText += (StringBuffer + "\n");
}
    
18.04.2015 / 21:19
0

Use the setLines method:

link

or in the xml property:

android:lines
    
18.04.2015 / 18:44
0

You should use "\ n" for tabbing, if you want to concatenate with other information, you should use the +     

28.04.2017 / 02:11