本文介紹了Android大寫字符在手機中不起作用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
限時送ChatGPT賬號..
在我的應(yīng)用中,我想讓用戶只輸入大寫字母.所以我使用大寫屬性.
in my app, I want to allow the user to enter only upper case letters. So I used capitalize property.
這是代碼的一部分
<EditText
android:id="@+id/et5"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_x="127dp"
android:layout_y="219dp"
android:maxLength="25"
android:ems="10"
android:singleLine="true"
android:capitalize="characters"
android:text="" />
在某些情況下我也試過這個
In some cases I also tried this
android:inputType="textCapCharacters"
在模擬器中可以正常使用,但在手機中無法使用.在電話中,它顯示小寫字母.這里的錯誤是什么以及如何克服?
It works fine in emulator, But it is not working in phone. In phone, it shows lower case letters. What is the mistake here and how to overcome?
推薦答案
試試這個:
editText.setFilters(new InputFilter[] {new InputFilter.AllCaps()});
并將 EditText xml 屬性設(shè)置為:
and set EditText xml property to:
android:inputType="text|textCapCharacters"
希望對你有幫助:)
這篇關(guān)于Android大寫字符在手機中不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!