Converting EditText to int? (Android)

前端 未结 11 1207
深忆病人
深忆病人 2020-12-09 03:08

I am wondering how to convert an edittext input to an int, I have the user input a number, it than divides it by 8.

MainActivity.java

@SuppressWarnin         


        
11条回答
  •  無奈伤痛
    2020-12-09 03:41

    you have to used.

    String value= et.getText().toString();
    int finalValue=Integer.parseInt(value);
    

    if you have only allow enter number then set EditText property.

    android:inputType="number"
    

    if this is helpful then accept otherwise put your comment.

提交回复
热议问题