Converting EditText to int? (Android)

前端 未结 11 1242
深忆病人
深忆病人 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:57

    Try this,

    EditText x = (EditText) findViewById(R.id.editText1);
    int n = Integer.parseInt(x.getText().toString());
    

提交回复
热议问题