EditText print $ when pressed 4

I have an EditText where I only allow $ 0123456789 characters.

Everything works well, except when I press number 4 (on a virtual or hardware keyboard) it prints a dollar sign ($).

Why is this done?

Here is the XML for my EditText:

<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" /> 

Secondary Question:

 mAmountTxt.setKeyListener(DigitsKeyListener.getInstance(false, true)); 

This is achieved by what I want (without $). However, it changes the virtual keyboard to what I don't want. I want a phone keypad with large button numbers.

+4
source share
2 answers

First, I'm 100% sure that it is not directly related to your EditText XML text. I tried your xml in Emu 2.1, Emu 4.0, Emu 4.1 and Real Phone 4.0, and it worked well in each.

Other possible causes:

  • It can be an emulator - they are sometimes erroneous. Can you try to create a new instance of the emulator and test it? Or try restarting adb?

  • It could be something software. Are you replacing or something like that?

  • I'm not sure what this does: style="@style/textbox"


Secondly, to make the keyboard layout look like a phone, use this instead of setKeyListener

 mAmountTxt.setInputType(InputType.TYPE_CLASS_PHONE); 
+1
source

You wrote:

 I want the phone keyboard with the big number buttons. 

Set inputType to:

 android:inputType="phone" 

instead:

  android:inputType="textPhonetic|numberDecimal" 
0
source

Source: https://habr.com/ru/post/1447388/


All Articles