問題描述
我正在開發一個小型個人待辦事項列表應用程序,到目前為止一切都運行良好.我想弄清楚一個小怪癖.每當我去添加一個新項目時,我都會有一個對話框,里面顯示一個 EditText 視圖.當我選擇 EditText 視圖時,鍵盤會按原樣輸入文本.在大多數應用程序中,默認值似乎是第一個字母的 shift 鍵......盡管在我看來它并沒有這樣做.必須有一種簡單的方法來修復,但我反復搜索了參考資料,但找不到.我在想適配器加載的引用必須有一個 xml 屬性,但我不知道它是什么.
靜態(即在你的布局 XML 文件中):在你的 EditText
上設置 android:inputType="textCapSentences"
代碼>.
以編程方式:您必須在 EditText
的 InputType
中包含 InputType.TYPE_CLASS_TEXT
,例如
EditText 編輯器 = new EditText(this);editor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
<塊引用>
可以結合文本及其變體來請求每個句子的第一個字符大寫.
- Google 文檔
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 new item, I have a Dialog with an EditText view showing inside. When I select the EditText view, the keyboard comes up to enter text, as it should. In most applications, the default seems to be that the shift key is held for the first letter... although it does not do this for my view. There has to be a simple way to fix, but I've searched the reference repeatedly and cannot find it. I'm thinking there has to be an xml attribute for the reference loaded by the Adapter, but I can't find out what it is.
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
這篇關于EditText 的首字母大寫的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!