Skip to content Skip to sidebar Skip to footer

Getting A Value Of Int From Edittext

I am trying to get a value from the edittext then cast it to int so that I can process the value for a substraction/additon/and so on. Here is the code I use, but I keep getting cr

Solution 1:

I think when you run your program then edit text have no value that means it will return NULL and NULL can't be a Integer value so you must have to check Condition Like

String editTextValue = number.getText().toString(); if(!TextUtils.isEmpty(editTextValue)){ angka = Integer.parseInt(editTextValue); }

I hope its work for you.

Post a Comment for "Getting A Value Of Int From Edittext"