문제

I have searched in many threads and could not find the fix .

In the EditText, I have entered a paragraph as below .

"Testing Description (I am pressing the enter key in the keyboard, it is taking me to the next line). This is just for testing "

and when i get the text and print in LogCat using .getText.toString() it is displaying me in the 2 lines . "Testing Description" in one line and it is re-printing the logcat with " This is just for testing"

How to get this in the same string . I get this issue only while pressing the enter key in the keyboard and proceeding the typing .

Actually i want to type a paragraph in the editText and get it in the Single string .

Thanks in Advance .

도움이 되었습니까?

해결책

How to get this in the same string . I get this issue only while pressing the enter key in the keyboard and proceeding the typing .

It always the same string. If you want it on the same line you can try string.replace() to strip away line breaks. For instance

String content = editText.getText.toString();
content = content.replace("\n", "");

다른 팁

When you press enter, there is a special character '\n' enters in your string..It is basically a single string and you just have to remove or replace this character. For this you can use yourString.replace("\n", "");

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top