Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting from Editable to int in android

Tags:

android

I want to convert the type Editable from an android EditText to the type integer to do maths operations on a user input number

I tried the following:

int x=(int)R2.getText().toString();

but it gives me an error of cannot convert a string to int.

like image 980
sherif Avatar asked Dec 12 '10 15:12

sherif


1 Answers

Fine, I got the answer:

int x = Integer.parseInt(R2.getText().toString());
like image 82
sherif Avatar answered Oct 14 '22 15:10

sherif