Android Dynamic Forms

(0 ratings)
Android Dynamic Forms | App Code for Sale | Hero

Screenshots

Overview

Android Dynamic Forms is the perfect tool for those who want dynamically generated forms on their android devices without having to deal with complicated user interface development. Just describe your form in json format, the application generates the native interface and on submit gives you the resulting json string for further processing.

Features

  • describe form in json ( we provide 3 samples)
  • load json in application( follow the code in sample MainActivity)
  • the form in native android components is generated
  • fill in form's fields
  • result is serialized in json
  • field types supported - drop down lists(spinner), radio buttons, edit text, date (format dd/mm/yyyy), hidden
  • relations between fields supported (enable field on completion of another field, enable field on completing related field with a certain value)
  • default values supported
  • series for lists and radio buttons can be defined globally

Limitations

  • when default values are provided you must take care of related fields initial status
  • radio buttons are displayed only in vertical orientation
  • relations can be defined only if the related field was previously defined in form. Only one relation can be defined for a field
  • date format is dd/mm/yyyy
  • hidden field can only have source sharedPreferences ( this means that if an attribute with the same name as field property value is placed in SharedPreferences under DynamicFormPrefs then at submit time this hidden field is populated if the value from SharedPreferences)

How to use

The bundle comes with a sample application targeting Android 2.3.3 containing three forms defined in json files (assets folder). It also contains a sources folder which can be used to create an Android application. Simply modify MainActivity to import your own json descriptions and provide this json to FormActivity. When FormActivity is finished a json with submitted data is returned to MainActivity.

Json Format

{
// instance form id, is generated for ewach submitted form
"formId": "", 
// for now "Form" is the single type accepted
"type": "Form",
// your own form category id - must be unique
// for each form definition (you can put here any unique 
// string in order to identify the result)
"categoryId": "90b8b775-b14c-475e-b5b2-a842ec5043ed0",
//form label
"formLabel": "Form 2",
//global series are used for lists and radio buttons
//defined here and used everywhere 
"globalSeries": [
{
    "seriesId": "series_spinner",
    "values": ["Option 1",
    "Option 2",
    "Option 3",
    "Option 4",
    "Option 5"]
}],
//sections for better organizing fields
"sections": [{
    "sectionLabel": "Section C",
    //id unique 
    "sectionId": "1",
    //fields for this section
    "fields": [{
        //is this field enabled from the start or not
        "enabled": true,
        //property name of this field
        //(must be unique)  
        "property": "Date1",
        //label for this field - if provided then label 
        //is added before the field view
        "label": "Selection date",
        //relations with another field  
        "relations": [],
        //field type can be date - DateWidget view is created,
        //edittext - EditText view is associated,
        // list - Spinner view is associated
        //radio - Radio Group view is associated, 
        //hidden -  
        "type": "date",
        //Id of globalSeries for list or radio group    
        "seriesId": "",
        //source sharedPreference for hidden fields
        "source": "",
        //default value
        "defaultValue": ""
    },
    {
        "enabled": true,
        "property": "List1",
        "label": "Drop Down List",
        "relations": [],
        "type": "list",
        "seriesId": "series_spinner",
        "source": "",
        "defaultValue": "Option 2"
    },{
        "enabled": false,
        "property": "Response1",
        "label": "",
        "relations": [{
            //property value of related field   
            "dependsOn": "List1",
            //relation type - in this case it means that 
            //when List1 has value Option 1
            //then Response1 is enabled
            // can also be enabled_on_completion which means that 
            //Response1 is enabled when List1 is completed
            "relationType": "enabled_on_value",
            //value of related field to trigger relation
            "relationValue": "Option 1"
        }],
        "type": "edittext",
        "seriesId": "",
        "source": "",
        "defaultValue": ""
    },      {
        "enabled": false,
        "property": "Response2",
        "label": "Related Comments (additional data)",
        "relations": [{
            "dependsOn": "Response1",
            "relationType": "enabled_on_value",
            "relationValue": "Sample"
        }],
        "type": "edittext",
        "seriesId": "",
        "source": "",
        "defaultValue": ""
    }]
}]

}

0 Comments Leave a comment