This code is throwing a invocationTargetException.
There are a few problems with this code:
- It is still entering the if statement even though I specifically told it not too when nothing is input into the
EditText. - I am guessing the exception could have occurred because of the
parseIntnot having anything to parse (Although that shouldn’t be a problem). -
A cause of this type exception should be not initiating something at the right time, should it not?
if(ageText.getText().toString() != "" || ageText.getText().toString() != null) { newCharacterController.characterAge = Integer.parseInt(ageText.getText().toString()); }
A little off topic too, I cant seem to find the tag of any of the containers like a Spinner or EditText, when I look into the mTag value of it when the program is running, will this affect my if(parent.getTag() == "OBJECTIDGIVENBYMYSELF") and stop if from working? Also is there a better way to gain the tag value (.getType() in C#).
An example of the above OBJECTNAMEGIVENBYMYSELF is EditText ***newEditText*** = new EditText(this);.
The above code is not a good practice to compare String content, simply because comparison operator such as “==” is used to compare by reference but not value. I think you should use the following code instead
And by the way, check null before this.