gpt4 book ai didi

android - Edittext 给出换行字符串而不是字符串

转载 作者:行者123 更新时间:2023-11-29 21:38:56 24 4
gpt4 key购买 nike

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:""

最佳答案

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

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

关于android - Edittext 给出换行字符串而不是字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17636534/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com