Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New line (\n) not Supporting in android?

I am trying to split the single string in to two lines using \n in android but it shows as it is with \n too. I am expecting below,

String new = "Hi, How are you";

In EditText box I need,

Hi,

How are you

I know its simple question but I couldn't find a solution.

like image 619
vinothp Avatar asked Nov 29 '22 15:11

vinothp


2 Answers

I think you are new into android development like me. It's really easy to do...

You just have to do this:

editText.setText("Hi,\nHow are you?");
like image 60
MAC Avatar answered Jan 04 '23 00:01

MAC


It's "\n" - a backslash, not a forward slash.

See this related question for more information about how to make a multiline text view look right.

like image 26
ravuya Avatar answered Jan 03 '23 22:01

ravuya