Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText textCapSentences does not work

I try to make text starts with uppercase first letter. Using attr inputType

<EditText
        android:id="@+id/add_user_fname"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/margin_size_small"
        android:inputType="textCapSentences|textPersonName"
        android:capitalize="sentences"
        android:layout_toRightOf="@id/user_avatar"
        android:hint="@string/add_user_fname"
        android:maxLength="@integer/name_max_length"
        android:singleLine="true"
        android:textSize="@dimen/text_size_small" />

and set in code

userFnameEditText.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);

but nothing works. All of this places in DialogFragment.

Updated I removed setInputType in code and set only inputType="textCapSentences". It works on Android 4, but doesn't work on Samsung Android 5

like image 774
elya_a Avatar asked Mar 10 '26 06:03

elya_a


2 Answers

I had the same problem. But, I found a solution that help me: Be sure that your "Auto Capitalization" settings is checked on keyboard settings. This works on Nexus 4.

Reference: http://www.ercanbaran.com/textcapsentences-not-working/

like image 144
Mauricio Barbosa Avatar answered Mar 11 '26 20:03

Mauricio Barbosa


Edited Try it in your java file

TextView txtCapitalize = (TextView) findViewById(R.id.txtCapitalize);
txtCapitalize.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
like image 27
Varun Puravankara Avatar answered Mar 11 '26 21:03

Varun Puravankara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!