Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/RGirish/Build-Former
This is a library for building forms dynamically in Android.
https://github.com/RGirish/Build-Former
android dynamic forms json
Last synced: 2 months ago
JSON representation
This is a library for building forms dynamically in Android.
- Host: GitHub
- URL: https://github.com/RGirish/Build-Former
- Owner: RGirish
- License: apache-2.0
- Created: 2015-10-09T00:00:54.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-25T06:08:41.000Z (almost 8 years ago)
- Last Synced: 2024-08-01T21:47:23.933Z (5 months ago)
- Topics: android, dynamic, forms, json
- Language: Java
- Homepage:
- Size: 717 KB
- Stars: 23
- Watchers: 2
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-android - Build-Former - This is a library for building forms dynamically in Android. (Uncategorized / Uncategorized)
README
# 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
3. RadioGroupRatings - a special kind of customized RadioGroup
4. Checkbox
5. CheckboxGroup
6. Switch
7. DropdownList
8. DatePicker
9. TimePicker
10. 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'
```