When I set the textView line manually as shown below, it works.
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="line 1 \n line 2"/>
However, when I try to show a String in this text element, it does not jump to a new line.
String sample = "line 1 \n line 2";
textView1.setText(sample);
Note. In fact, I get the row from the SQLite database. But it should not matter? Beacause is another line!
sample = cursor.getString(DBAdapter.COL_sample);
textView1.setText(sample);
So now my TextView shows the character "\ n" or "\ r \ n" instead of a line break.
source
share