Reputation: 10069
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.
Upvotes: 4
Views: 21649
Reputation: 5457
In your case, replace "/n"
and with "\n"
and also if you need more then one EditText
, then you must edit properties of EditText
as below:
android:singleLine="false"
android:MaxLines = "5"
if you know the exact number of lines.
Upvotes: 4
Reputation: 15847
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?");
Upvotes: 10
Reputation: 8852
yes "\n"
is supported in android, unfortunately "/n"
is not supported yet ;)
Upvotes: 0
Reputation: 8766
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.
Upvotes: 9