How do I return an int from EditText? (Android)

后端 未结 4 1574
悲&欢浪女
悲&欢浪女 2020-12-04 09:52

Basically, I want an EditText in Android where I can have an integer value entered into. Perhaps there is a more appropriate object than EditText for this?

4条回答
  •  没有蜡笔的小新
    2020-12-04 10:24

    Set the digits attribute to true, which will cause it to only allow number inputs.

    Then do Integer.valueOf(editText.getText()) to get an int value out.

提交回复
热议问题