Android Question Capitalize all words

johnmie

Active Member
Licensed User
Longtime User
From an earlier Erel reply I learned how to capitalize the first letter in an editText field with Bit.Or...

Is there a trick to do this for every word, eg. Firstname Lestname? Ideally (optional) only if a word has more then 3 letters, e.g. Ludwig van Beethoven?

I know how to do this postpartem, but not while typing. Tried txt.InputType =txt. Input.INPUT_TYPE_TEXT_FLAG_CAP_WORDS but this does not work, unfortunately.

Can you help? Thanks a lot, john m.
 

MikeSW17

Active Member
Licensed User
Longtime User
Just remember, if you are primarily working with names of people, or wider all Proper Nouns, you will need to deal with quite a few exceptions, not just a 3 letters or more check.
For examples: O'Grotes ; McDonald; MacLysaght. - just a few in the English language. Heaven knows how many internationally.
Another example, the (chinese?) surname "Ng" would fail your 3 letters length.
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Can you help?
The only way this will have a chance to work is if you're doing it in a very narrow scope. (Actually, such a narrow scope that I can't even come up with an example.)

In all other cases you're most likely creating a situation with bad user experience. I would recommend not doing it. Just let people case their names as they like, and move on to other challenges.
 
Upvote 0

johnmie

Active Member
Licensed User
Longtime User
Thank you all for your input. I realize this is too complex, so I'll follow Sandman's advise and just capitalize the very first letter.
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
From an earlier Erel reply I learned how to capitalize the first letter in an editText field with Bit.Or...

Is there a trick to do this for every word, eg. Firstname Lestname? Ideally (optional) only if a word has more then 3 letters, e.g. Ludwig van Beethoven?

I know how to do this postpartem, but not while typing. Tried txt.InputType =txt. Input.INPUT_TYPE_TEXT_FLAG_CAP_WORDS but this does not work, unfortunately.

Can you help? Thanks a lot, john m.
The value I've used in the past for cap words is "0x00002000", try setting your input type to that value and see if it works on your device.
 
Upvote 0

johnmie

Active Member
Licensed User
Longtime User
Thank Jeffrey. The value works indeed to capitalize every word, but as MikeSW17 and Sandman have pointed out, it does not resolve the name prefix. This is now a minor problem: Ludwig van Beethoven simply has to press the shift key when entering the v and Mike O'Cool when entering the C (will explain to users under "help").
 
Upvote 0
Top