Android emulator : insert negative number?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-11 08:31:14

问题


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.


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




回答2:


In resource file .axml, EditBox change type

android:inputType="numberDecimal"

to

android:inputType="numberDecimal|numberSigned"

It works for me




回答3:


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



回答4:


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


来源:https://stackoverflow.com/questions/9133937/android-emulator-insert-negative-number

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!