Android Edittext指定新行字符串而不是字符串

Android Edittext指定新行字符串而不是字符串,android,android-edittext,Android,Android Edittext,我的应用程序中有一个edittext。当我在edittext中按enter键时,将转到新行/n。我的问题是获取带有“\n\n\n”(3次按enter按钮)的edittext值。但是我想要空字符串值,如“”。如何解决此问题谢谢 输出为: 但是我想要 您将需要解析字符串变量。这可以使用String类的replace(charoldchar,charnewchar)方法完成 task.replace("\n", ""); TaskName:"\n\n\n" TaskName:"" task.re

我的应用程序中有一个edittext。当我在edittext中按enter键时,将转到新行/n。我的问题是获取带有“\n\n\n”(3次按enter按钮)的edittext值。但是我想要空字符串值,如“”。如何解决此问题谢谢

输出为:

但是我想要


您将需要解析字符串变量。这可以使用String类的replace(charoldchar,charnewchar)方法完成

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