Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prepend a String to an Android TextView?

There's TextView.append(), but that adds the text to the end of the TextView. I want what I append to go in the beginning (ie, show up on the top of the TextView box).

like image 489
Tim Avatar asked Aug 15 '12 18:08

Tim


People also ask

How do I add a newline to a TextView in android?

Add Line Breaks to a TextView Just add a \n to your text. This can be done directly in your layout file, or in a string resource and will cleanly break the text in your TextView to the next line.

What is the use of append in android?

append. Appends the specified character sequence to this Appendable . Depending on which class implements the character sequence csq , the entire sequence may not be appended. For instance, if csq is a CharBuffer then the subsequence to append is defined by the buffer's position and limit.


1 Answers

Have you tried this

 textview.setText(" append string" + textView.getText());

Though the spannables will get lost by this method.

like image 194
nandeesh Avatar answered Sep 21 '22 16:09

nandeesh