Android emulator: insert a negative number?

I suppose this should be easy, but how to insert a negative number in EditText?

I am running an emulator on a Mac.

Thank.

+5
source share
4 answers

Just press "-" before entering the number?

If this is not possible, maybe something is wrong with the inputType editText. For example, android:inputType="numberDecimal"does not allow negative numbers. In this case, you need to add: android:inputType="numberDecimal|numberSigned".

+21
source

In the .axml resource file, editbox edit type

android:inputType="numberDecimal"

to

android:inputType="numberDecimal|numberSigned"

It works for me

+4
source
EditText yourEditText = (EditText)findViewById(R.id.yourEditText);
yourEditText.setText("whatever");
+2
editText.setText(String.valueOf(-1));
+2

All Articles