Android Componentized Forms with Ogya

There are hardly any android apps built without forms. It can be daunting especially when you have forms all over the place. Usually they lead to never ending xml files or really long xml files. And then there is the case where the form contains other elements which are not inputs eg info cards, images etc. Most at times we will just repeat the form code in all xmls that they are needed in or probably use the include tag (but there is no for-loop for (not that I know of though.)). We have already achieved component reuse by Componentization in Ogya. All we needed to do was to

1. Add a component that can accept input.

I see the confusion in type and inputType. So lets break that down.

type This just toggles between date,time and input. Basically they are all inputs but time gives you the opportunity to select from the android TimePicker, date also does the same but gives you a DatePicker instead. Both type time and date gives you an un-editable input. Type input allows you to use the keyboard as the input source.

2. Decide the keyboard type based on the input.

As you can see the inputType parameter expects the android textInput type. Pass any of these and you will get its respective keyboard.

3. Add a watcher to track value changes of input element.

This means you can pass any layout you prefer. Just make sure of the following.

2. Your component’s signature is

ListableAdapter has been extended with one more function : retrieveFormValues

And you use it like this:

And that’s it!

Software Engineer with great love for Mathematics especially Abstract Mathematics.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store