Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write a paragraph using textview on Android

I want to write a paragraph as part of my mobile application. How do I go about it?

like image 818
user590849 Avatar asked Feb 18 '11 11:02

user590849


2 Answers

Use \n to break line.

Example:

TextView t = findViewById(R.id.text);
t.setText("This is the first line\nThis is the second line\nThird line...");
like image 58
neteinstein Avatar answered Nov 12 '22 19:11

neteinstein


<?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>

So you can make a reference to it like:

android:text="@string/text_with_paragraphs"

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

like image 39
Asif Mushtaq Avatar answered Nov 12 '22 20:11

Asif Mushtaq