Android emulator : insert negative number?

三世轮回 提交于 2019-12-01 18:07:41

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

In resource file .axml, EditBox change type

android:inputType="numberDecimal"

to

android:inputType="numberDecimal|numberSigned"

It works for me

EditText yourEditText = (EditText)findViewById(R.id.yourEditText);
yourEditText.setText("whatever");
editText.setText(String.valueOf(-1));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!