I have a edit text field in which reason can be entered. But if a person enters all spaces in the reason how can I detect it. Is there a way when a person enters all spaces or nothing , i have to save the text the text as a simple “hiphen”. My main question is how to trim those spaces coming at the end.
Share
The method trim() in String trims excess spaces on Strings.
str2 would equal “Hello”.
As for detecting when a person enters all spaces – check the str.length() after you’ve ran str.trim().