2011-02-18 20 views
7

Quiero escribir un párrafo como parte de mi aplicación móvil. ¿Cómo lo hago?Escribir un párrafo usando textview en Android

+1

¿Qué quiere decir con un párrafo? ¿Qué características especiales desea que no se puedan cumplir con un TextView normal? tal vez usted está pensando en esto http://stackoverflow.com/questions/2979433/in-an-android-textview-is-it-possible-to-insert-paragraphs? – Adinia

Respuesta

11

Use \ n para romper la línea.

Ejemplo:

TextView t = findViewById(R.id.text); 
t.setText("This is the first line\nThis is the second line\nThird line..."); 
+0

yup se cansó, funciona. – user590849

4
<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <string name="text_with_paragraphs"> 
     Can this contain a lot of text? Can it contain \n a newline? Yes, it can. 
     Adding a 2nd line like this should work. 
     It should not cause parsing errors. 
    </string> 
<resources> 

para que pueda hacer una referencia a él como:

android:text="@string/text_with_paragraphs" 

Referencia: http://www.experts-exchange.com/Programming/Smartphones/Android/Q_27925834.html

0

Ésta ha trabajado para mí:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <string name="text_with_paragraphs"> 
     Can this contain a lot of text? Can it contain \n a newline? Yes, it can. 
     Adding a 2nd line like this should work. 
     It should not cause parsing errors. 
    </string> 
<resources> 

android:text="@string/text_with_paragraphs" 
+0

¿Está respondiendo a la respuesta de [usuario * UnKnown *] (http://stackoverflow.com/questions/5040574/write-a-paragraph-using-textview-on-android/30107753#30107753)? –