Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android EditText("Textbox") : Auto capitalizing first letter of each word while user typing

I know this question has asked several times but non of the answers worked in my case.

I found some of the same sort of questions and answers in the following links , which didn't work for me at all.

LINK1

LINK2

In my layout file, I have defined my EditText as follows.

 <EditText
    android:id="@+id/test_editText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_marginTop="90dp"
    android:inputType="textCapWords"
    android:ems="10" >

Also in the Activity class in the onCreate method I have added the following code.

    EditText testEditText = (EditText) findViewById(R.id.test_editText);
    testEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS); 

If someone have experienced the same issue and solved it would like to hear what I have done wrong in my case. Thanks.

Edits...

Following above explained steps I am unable to make this get it done(Auto capitalizing the first letter of each word while user typing).

According to my code, When user typing it displays first charater in all the words (including first word) in lower case.

like image 614
JibW Avatar asked Jun 11 '13 10:06

JibW


People also ask

How do you capitalize the first letter in Word on Android?

If you are using an Android phone and Gboard, you can capitalize the first letter of any word with three touches. First, double-tap the word in question to highlight the word, then tap the shift button (the up arrow) on the keyboard to capitalize the first letter. Done!

How do I Auto capitalize first word?

To use a keyboard shortcut to change between lowercase, UPPERCASE, and Capitalize Each Word, select the text and press SHIFT + F3 until the case you want is applied.


1 Answers

testEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);   

or android:inputType="textCapSentences" 

will only work If your device keyboard Auto Capitalize Setting enabled.

like image 97
Lakshmanan Avatar answered Oct 25 '22 17:10

Lakshmanan