mardi 27 mars 2018

Android - Is it ok to have too many OnCheckedChangeListeners?

I'm doing this Android App that has a lot of EditText fields, and each one of them has a checkbox next to it.

I'm implementing listeners to those checkbox:

checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {...});

Those listeners enable/disable the possibility to edit those EditTexts.

The thing is, i'm creating a new listener for EVERY checkbox, right? I have 34 checkboxes, so there are 34 instances of OnCheckedChangeListener running at the same time...

My questions are: Should I use another approach to this situation(better design pattern maybe)? Can I use only 1 instance, and reuse it in every checkbox?

Thank you for your future answers.




Aucun commentaire:

Enregistrer un commentaire