Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In an Android TextView, is it possible to insert paragraphs?

Below is an example of the type of problem that I have. I have data in a pojo that I need to display in a textview... the data has pseudo code that denotes each paragraph with [p]

I would like to somehow parse the [p]'s into paragraphs when they are displayed in the textview. Can this be done? Is there something I can substitute for the [p] that will make a new paragraph in the textview?

Question question = new Question();
question.setText("Here is the first paragraph.[p] And this should be the second."); 

TextView view = (TextView) findViewById(R.id.qtext);
view.setText(question.getParsedText());
like image 771
JohnRock Avatar asked Jun 05 '10 06:06

JohnRock


1 Answers

TextView tw = findViewById(R.id.t);
tw.setText("first line\nsecond line\nthird line");
like image 129
pankaj sharma Avatar answered Sep 23 '22 17:09

pankaj sharma