Skip to content Skip to sidebar Skip to footer

Android Emulator : Insert Negative Number?

I suppose it must be easy but how do I insert a negative number in an EditText? I am running the emulator on a Mac. Thank you.

Solution 1:

Just press '-' before you enter the number?

If that's not possible, there is probably something wrong with the inputType of the editText. For example, android:inputType="numberDecimal" doesn't allow negative numbers. In that case you should add: android:inputType="numberDecimal|numberSigned".

Solution 2:

In resource file .axml, EditBox change type

android:inputType="numberDecimal"

to

android:inputType="numberDecimal|numberSigned"

It works for me

Solution 3:

EditTextyourEditText= (EditText)findViewById(R.id.yourEditText);
yourEditText.setText("whatever");

Solution 4:

editText.setText(String.valueOf(-1));

Post a Comment for "Android Emulator : Insert Negative Number?"