JsonToForms

A simple library that uses JSON to create forms: JSON Form Builder.

A simple library which uses JSON to build forms

Setting

Step one. Add the JitPack repository to your :

Deposits {
.
maven { url ‘https://jitpack.io’ }
}

Step two. Add an addiction

Dependencies {
implementation of com.github.MohdShamweel:JsonToForms:0.1.0.

// support material dependency
implementation ‘com.google.android.material:material:1.1.0-alpha09’
}

Step three. The dependency contains the Java 8 bytecode. For build.gradle, add the following

android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}

Step four. Activities that include forms should be descendants of the material theme:

parent=Theme.MaterialComponents.Light.DarkActionBar

Step Five. Sync the project so the gradle is ready.

Use

  1. Initializing the hashmap (basically, it clears the list) :

DataValueHashMap.init() ;

  1. Use an adapter and an object from this library:

FormAdapter mAdapter ;
List jsonModelList = new ArrayList<>() ;

  1. Initialize the adapter:

mAdapter = new FormAdapter(jsonModelList, this, that) ;

  1. Implement your access methods activities

implements the JsonToFormClickListener

  1. Methods used

@Public Void Review
onAddAgainButtonClick() {
Toast.makeText(this, Re-add button click, Toast.LENGTH_SHORT).show();
}

@Check public blank
onSubmitButtonClick() {
Toast.makeText(this, Add button click, Toast.LENGTH_SHORT).show();
}

  1. To check if the fields are checked, use this method:

if (!CheckFieldValidations.isFieldsValidated(recyclingerView, jsonModelList)){
Toast.makeText(this, Validation Failed, Toast.LENGTH_SHORT).show();
}

  1. To obtain the data :

// Combined data :
JSONObject jsonObject = new JSONObject (DataValueHashMap.dataValueHashMap);
Log.d(onSubmitButtonClick: jsonObject.toString())

// When a value is needed for the corresponding _id :
For (Map.Entry<String, String> hashMap:DataValueHashMap.entrySet()){
String key = hashMap.getKey(); // _id JSONOModel provided
String value = hashMap.getValue(); // value entered for corresponding _id
Log.d(key, value);
}

Field types

TYPE_TEXT = 1 ;
TYPE_EDITTEXT = 2 ;
TYPE_SPINNER = 3 ;
TYPE_RADIO = 4 ;
TYPE_DATE = 5 ;
TYPE_SPACE = 6 ;
TYPE_CHECKBOX = 7 ;
TYPE_ADD_AGAIN_BUTTON = 9 ;
TYPE_SUBMIT_BUTTON = 10 ;

JSON example

[
{
_id : text_1,
text : Hello! Check of text, reference
: Hello! I check the SMS,
type: 1
},
{
_id: text edit_1,
text : Hello! I edit the text (enter numbers), request
: Hello! I modify the text (enter numbers),
input_type: numbers,
max_length: 2,
type: 2
},
{
_id: editxt_2,
text : Hello! I am editing a text (entering decimal places), request
: Hello! I modify the text (enter numbers decimal),
input_type: numbers_decimal,
max_length: 7,
type: 2
},
{
_id: editxt_3,
text : Hello! I change text (enter text) *Question, question
: Hello! I edit text (enter text),
input_type: text,
is_required: true,
max_length: 30,
type: 2
},
{
_id: radio_group_1,
text : Hello! Radio group I,
required: true, list
: [
{
index: 0,
index_text : Radio 1
},
{
-index: 1,
-index_text : Radio 2
},
{
-index: 2,
-index_text : Radio 3
},
{
-index: 3,
-index_text : Radio 4}], type: 4},{_id: spinner_1,text: Hello! I Spinner, list: 0,index_text : Element 1
},
{index
: 1,
index_text : Element 2
},
{
-index: 2,
-index_text : Element 3
},
{
index: 3,
index_text : Element 4
}
], type
: 3
},
{
_id: again_button,
text : Hello! I add a button, type
: 9
},
{
_id : space_1,
text : Hi, I’m Space, type: 6},{_id: submit_button,text : Imagine type
: [ 10
}
]

Example:

For more information on implementation, see the application template.

Item

Withdrawal requests are welcome. For major changes, first ask what you want to change.

Don’t forget to update the tests if necessary.

GitHub

generate html form from json schemagenerate ui from jsonjson forms examplejson form playgroundjson forms angularjson forms githubconvert json to html formjson forms vue

You May Also Like

TimeFinder SnapVX Concepts and SnapVX Operations – The Geek Diary

SnapVXTimeframe Search Overview The TimeFinder SnapVX provides a highly efficient mechanism for…

How to Set Up GameLoop on your PC?

GameLoop is a great Android emulator used by many users for Tencent…

🥇 Search Information in Slack  Step by Step Guide ▷ 2020

For a faster search in Slack to access your workgroup information, it…

Best Windows 10 Clipboard Manager To Ease The Copy Paste Work

The copy/paste function is the most commonly used when working on a…