elya_a elya_a - 6 months ago 83
Android Question

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

Answer

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);
Comments