Satheesh
Satheesh

Reputation: 1730

Edittext give the new line string instead of string

I have one edittext in my application.when i press the enter key in edittext that will be go to new line /n.My problem is get the edittext value which have "\n\n\n"(3time press enter button).But i want empty string value like "".how to solve this isuue thanks...

String task =editboxTask.getText().toString();
Log.i(TAG,"TaskName:"+task);
if (!checkTask.isEmpty()) {
   }

Output is:

TaskName:"\n\n\n"

But i want

TaskName:""

Upvotes: 1

Views: 411

Answers (1)

frogmanx
frogmanx

Reputation: 2630

You will need to parse the string variable. This can be done using the replace(char oldChar, char newChar) method of the String class.

task.replace("\n", "");

Upvotes: 2

Related Questions