[英]EditText printing $ when 4 is pressed
我有一個EditText,我只允許字符$ 0123456789。
一切都運行良好,除非我按下數字4(在虛擬或硬件鍵盤上),它打印一個美元符號($)。
它為什么這樣做?
這是我的EditText的XML:
<EditText
android:id="@+id/amount_text"
style="@style/textbox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@null"
android:cursorVisible="false"
android:digits="$0123456789."
android:gravity="left|center_vertical"
android:hint="@string/amount_hint"
android:inputType="textPhonetic|numberDecimal" />
次要問題:
mAmountTxt.setKeyListener(DigitsKeyListener.getInstance(false, true));
這實現了我想要的(沒有$)。 但是,它將虛擬鍵盤更改為我不想要的鍵盤。 我想要帶有大號按鈕的手機鍵盤。
首先,我100%確定它與您的EditText xml沒有直接關系。 我已經在Emu 2.1,Emu 4.0,Emu 4.1和Real Phone 4.0中嘗試過你的xml,並且每個都運行良好。
其他可能的原因:
它可能是模擬器 - 它們有時是錯誤的。 您可以嘗試創建模擬器的新實例並進行測試嗎? 或者,嘗試重新啟動adb?
它可能是程序化的東西。 你做任何替換或類似的事情嗎?
我不確定這是做什么的: style="@style/textbox"
其次,要使鍵盤布局看起來像手機,請使用此代替setKeyListener
mAmountTxt.setInputType(InputType.TYPE_CLASS_PHONE);
你寫了:
I want the phone keyboard with the big number buttons.
將inputType
設置為:
android:inputType="phone"
代替:
android:inputType="textPhonetic|numberDecimal"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.