First letter capitalization for EditText

后端 未结 17 2028
傲寒
傲寒 2020-11-28 01:11

I\'m working on a little personal todo list app and so far everything has been working quite well. There is one little quirk I\'d like to figure out. Whenever I go to add a

17条回答
  •  再見小時候
    2020-11-28 02:08

    Statically (i.e. in your layout XML file): set android:inputType="textCapSentences" on your EditText.

    Programmatically: you have to include InputType.TYPE_CLASS_TEXT in the InputType of the EditText, e.g.

    EditText editor = new EditText(this); 
    editor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    

    Can be combined with text and its variations to request capitalization of the first character of every sentence.

    - Google Docs

提交回复
热议问题