Coder Social home page Coder Social logo

build-former's Introduction

BuildFormer

This is a dynamic form builder library for Android. Given a LinearLayout to build on, dynamically creating views such as Switches, TextViews, EditTexts and lots more, becomes as easy as calling the methods in this library. Each of the supported views (listed below) has one or more methods within the library that can be called to create the view in the previously set LinearLayout.

The library is for Android developers who want to create any of these supported views dynamically. One kind of application where this library could prove to be immensely helpful would be in creating survey forms.

An example - Creating an EditText

LinearLayout layout = (LinearLayout) findViewById(R.id.myLinearLayout);

FormBuilder builder = new FormBuilder(this, layout);
builder.createEditText("Enter your name", FormBuilder.EDIT_TEXT_MODE_HINT, true);

// the first parameter is the description.
// the second parameter is a flag that tells the library to display the description as a hint.
// the third parameter if 'true', makes the EditText single-line.

JSON Export/Import

The library also provides methods to export the meta data of a dynamically created form into a JSON representation.

This way, a user is able to create a form with the help of this library and is then able to save it in an internal representation. The following is how it is done:

FormBuilder builder = new FormBuilder(this, layout);
builder.createTextView(...);
builder.createCheckbox(...);
builder.createRadioGroup(...);
builder.createEditText(...);
...
builder.exportAsJson("filename.json");

The JSON file is saved in the root directory of the ExternalStorage.

Once this is done, if we need to dynamically create the same form again, all we need to do is this:

FormBuilder builder = new FormBuilder(this, layout);
File file = new File(Environment.getExternalStorageDirectory() + File.separator + "filename.json");

try {
    builder.createFromJson(file);
} catch (IOException e) {
    ...
}

Supported views

  1. TextView
  2. EditText
  3. RadioGroup
  4. RadioGroupRatings - a special kind of customized RadioGroup
  5. Checkbox
  6. CheckboxGroup
  7. Switch
  8. DropdownList
  9. DatePicker
  10. TimePicker
  11. SectionBreak

Adding a dependency to this Library

The library is available in the jCenter() repository only:

compile 'com.girish.library.buildformer:buildformer:0.9.4'

build-former's People

Contributors

rgirish avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.