All- I have an app in which the user inputs values into multiple edittext fields and than the user taps a button to calculate all the numeric inputs into a formula and outputs the answer. My problem is that when one of the edittect fields is left empty the app force closes when the calculate button is hit. I know I can fix this by having an alert dialog box pop up when the calculate button is hit and there are one or more empty edittext fields. I don’t know how to put the alert dialog inside of an “if” statement. For example “if any one of the edittext fields are empty .show() this alert dialog”. Could someone please give me some sample code.
Share
If you have (or create) an array/list of all the
EditTextfields, you can run through them like thisYou can create a list of
EditTexts like this:and then just add