Say I am developing an app for an Object. The app lets user add Object, open its details and edit Object - a very common setup. I would create an AddObjectActivity which would contain all the input fields required to create Object. Once the Object is created - it can be edited and the edit activity should contain all the fields that create had. That means binding all the fields that create activity has and doing any layout setup - the same as create activity.
It seems to be that I have two options here: duplicate the code completely - create separate activities for add and edit actions OR reuse as much as possible and extend/introduce some kind of indicator indicating which of the actions(add or edit) is being performed.
Duplicating that much code feels wrong and the second option brings a lot of unneccessarty complexity.
This is a very common pattern in applications so I was wondering what is the best way of doing this in Android?
Aucun commentaire:
Enregistrer un commentaire