While entering String in EditText for example “Love Is Life” , after entering word “Love” enter space , then after if click the letter ‘i’ it automatically need to change it as Uppercase letter ‘I’ .
Which means the character after every Space of String need be in Uppercase and make the change dynamically while entering character in EditText to stimulate Camel case format.
If anyone knows means help me out.
Thanks.
You can add a TextWatcher to an
EditTextand get notified each time the text is notified. Using that, you can just parse the String to find the characters after a space, and update them to uppercase.Here’s a quick test I made which works pretty well (far from optimal, because each time you edit the Editable it calls the listener again…).
To avoid being called to often, you could make all the changes in a
char[]and only commit to theEditableif changes were made.A simpler solution is probably to just use
split(' ')on your String, replace all first letters in theString[]by the uppercase version (if needed), and commit only once to theEditable.A simpler optimisation would be to add a boolean to your anonymous class, set it to try when you enter afterTextChanged, set it back to false when you exit it, and only process the string if the boolean is false.