Automatic EditView capitalization

On 2010/05/10, in Android, Code, by ennaN

It was quite easy to make some of the input fields use the “auto caps” feature of android. Now while deadly for some people and a bit annoying for others, this was one of the first requests I got for AndroBlip .I’m not going to go for the autocomplete stuff, as this feels like a bridge to far.

Anyway, we were talking about android coding, not AndroBlip.
So there is an EditText view in the layout called “editTextId“, and we set it for Capitalization like so:

EditText myEditText = (EditText) findViewById(R.id.editTextId);
myEditText.setInputType(InputType.TYPE_CLASS_TEXT |
        InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);

Now i don’t know if you can do this in XML, but this works fine ;).

Leave a comment

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>