1

Got int'l android app, but whitespace characters in several languages are being recorded for things like a username. I need to prevent whitespace (regex: \S), but I can't seem to get TextWatcher implementation to check for them. Do I check each character in the CharSequence that's given? Even then, I can't seem to prevent that char from being entered originally.

In other words, how do I prevent tabs, spaces, carriage returns from being registered as a char input to an edittext.

Thoughts?

JBird
  • 211
  • 3
  • 12
  • You can find a nice answer here: http://stackoverflow.com/questions/3349121/how-do-i-use-inputfilter-to-limit-characters-in-an-edittext-in-android – Herrbert74 Feb 16 '12 at 08:59

1 Answers1

0

You trim() when your setting or getting the string in editText.

Like this:

String s = " someString ".
mEditText.setText(s.trim());

This will remove all the redundant white spaces. Ask if any doubts.

Shashank
  • 183
  • 1
  • 4