-2

i have the value like WORK but i want to set this to edit text like Work. Can anybody help me out?

Wasi Ahmad
  • 35,739
  • 32
  • 114
  • 161
Vikash Kumar
  • 395
  • 5
  • 17

3 Answers3

1

try this

<EditText
    android:id="@+id/txtCapitalize"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:inputType="textCapSentences" />

EditText txtCapitalize = (EditText) findViewById(R.id.txtCapitalize);
    txtCapitalize.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.

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
1

Configure your EditText with android:textAllCaps="false". Then programatically modify your variable as you want using String function as toLowerCase (for the all string) and toUpperCase(the first letter).

Mr_Perfect
  • 8,254
  • 11
  • 35
  • 62
Tristan.L
  • 11
  • 1
1
String str = yourEditText.getText().toString();
str = str.toUpperCase().charAt(0) + str.substring(1);
Wasi Ahmad
  • 35,739
  • 32
  • 114
  • 161
Fakhriddin Abdullaev
  • 4,169
  • 2
  • 35
  • 37