I have an activity with 20 EditTexts on it. I want to display a message if anything has been entered. Instead of attaching 20 listeners to each field, is there a way to know if input has been supplied(data changed)?
I have an activity with 20 EditTexts on it. I want to display a
Share
Here is an example of a base class that takes care of notifying subclasses if any of their
EditTextwidgets is being used(if any exist). Depending on what you want to do when the user inputs something you may need to change my example to suit your particular case.Base activity from which you’ll inherit:
Then all you have to do in your activities is implement the
onInputchangecallback to let you know that the user entered something in one of theEditTextsfrom the current layout. You may want to look at the key event callbacks from the activity class for something simpler, but if I’m not mistaken those events are consumed by theTextView/EditTextwidgets.