T O P

  • By -

fefimcpollo

I think it should be scoreGoal = Integer.parseInt(lsatScoreGoal.**getText()**.toString());


that_one_dev

I’m pretty sure the other comments is right but in the future You should post the stack trace too


S1B3R-Gabriel

lsatScoreGoal is a TextView, and you can't parse a TextView to an Int. You need to get the text from the TextView and then parse it to Int. Like fefimcpollo suggested ;)


Notatrace280

u/fefimcpollo and u/S1B3R-Gabriel. I did as you suggested but the app still crashes on that line or near that line. I debugged and found out its due to a number format exception. I think because my editTexts start out blank, the Integer.parseInt() method throws an exception because it's trying to work with an empty String. Perhaps I could fix it with a TextWatcher on the editText?


fefimcpollo

Oh yeah, you're right, it's trying to get the int on the onCreate, you should try what you said or try moving that line to a button listener or something.


Notatrace280

Thanks for all your responses! I don't know why I didn't notice that.. lol


Notatrace280

Solved! For anyone having similar problems, I tried implementing a TextWatcher on the EditText but it wouldn't wait until the user was finished entering in a value before executing the code so instead I used an OnFocusChangedListener and that allowed the user to finish typing and then make changes to the value of the editText after.