I did manage to publish my roman numeral converter application onto Google Play and I'm currently making updates to it. You can reference the app in this question I have asked here How to set textView as method output on android
I have replaced the original setText
methods with setHint
based on this question How to clear a editText on click.
However on my convert button listener when I've changed the try catch statements to setHint
Android Studio says it can result in a NullPointerException
.
Here is my code for reference:
try {
int integer = Integer.parseInt(intValue);
if (integer > 0 && integer <= 4999) {
numeralInput.setText(translator(integer));
} else {
numeralInput.setHint("Enter an integer from 1 to 4,999.");
}
} catch (NumberFormatException e) {
numeralInput.setHint("Invalid input try again.");
}
What can I do to change the hint without result in the exception?