I'm trying to build a complex form where almost all of the elements are optional. It starts with just a single field and an "add element" button. When you click add, the form shows a Spinner
of the types of elements you can add to the form (location, photo, detailed note, timestamp other than "now", etc). When you select an item, it will launch an Activity
, and each item has a different associated Activity
.
In addition, each choice will have several bits of data, which it would be nice to store "with" the Activity
somehow:
- An icon and the displayed name in the
Spinner
- A key for storing the data in the db (as well as passing to a webservice)
- A layout for how to display the result on the original form (i.e. a thumbnail for the photo, the lat/lon for the location, etc)
I was considering a set of classes that all extend an abstract FormElement
class, and would have static elements for each of the above extra pieces of data. (An additional bump for this solution is how much of a pain Resources
are in a static context.)
How can I make this as clean and maintainable as possible? I'd really not enjoy editing five different files to add a new type of element to this form. (Mostly because I can guarantee I'll miss one and spend hours chasing down unbugs.)