Android emulator : insert negative number?

2019-06-21 04:58发布

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.

4条回答
贼婆χ
2楼-- · 2019-06-21 05:04

In resource file .axml, EditBox change type

android:inputType="numberDecimal"

to

android:inputType="numberDecimal|numberSigned"

It works for me

查看更多
对你真心纯属浪费
3楼-- · 2019-06-21 05:06

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

查看更多
闹够了就滚
4楼-- · 2019-06-21 05:06
EditText yourEditText = (EditText)findViewById(R.id.yourEditText);
yourEditText.setText("whatever");
查看更多
我命由我不由天
5楼-- · 2019-06-21 05:12
editText.setText(String.valueOf(-1));
查看更多
登录 后发表回答