AN Android library that make Forms manipulation very easy fill form from view, flow form into view, proceed form validation
Form object is as simple HashMap Object. so you can put name value pair corresponding at form's fieldName, values.
Form form = new Form();
form.put("firstName","Toto");
form.put("lastName","Titi");
form.put("years",25);
form.put("someFieldName",mObject);
It is also possible to retrieve inserted value from your form Object Form object is as simple HashMap Object. so you can put name value pair corresponding at form's fieldName, values.
Object mObject = form.get("someFieldName");
int years = form.optInt("years");
String lastName = form.optString("lastName");
String firstName = form.optString("firstName");
It is possible to create Form from object or Object from form. to show that. i am creating some User.class with default constructor(necessary)
class User{
String firstName;
String lastName;
int years;
Object someFieldName:
}
Now, i can create an empty form from User.class.
Form form = Form.fromClass(User.class);
It is also possible to create not empty Form from an non empty Object instance.
User user = new User();
user.firstName = "Toto";
user.lastName = "Titi";
user.years = 25;
user.someFieldName = mObject;
Form form = Form.fromObject(user);
Form Entity provide possibility to turn them into object.
User user = form.as(User.class);
With ZFormx library, you can easily fill a view by flowing form content into. For this, you should insure that your view's Tag have same name with your form's field. So, let create some Xml layout View.
<?xml version = "1.0" encoding = "utf-8"?>
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
android:id = "@+id/form_layout"
android:layout_width = "match_parent"
android:layout_height = "match_parent">
<EditText
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:hint = "First Name"
android:tag = "firstName..." />
<EditText
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:hint = "Last Name"
android:tag = "lastName..." />
<EditText
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:hint = "Years..."
android:tag = "years" />
</LinearLayout>
Now , from my Activity, i can flow Form Entity into that created View which has id = R.id.form_layout.
View mFormView = findViewById(R.id.form_layout);
FormFlower.using(mForm) //create a flower using a specific Form Entity (mForm)
/*setFillAccessibleOnly spécify if you want to flow enabled view Only
(desabled view and not fowussable view would be ignored.)*/
.setFlowAccessibleOnly(false)
.flowInto(mFormView); //flow the form entity into the formView
Documentation in progress... :-)
View mFormView = findViewById(R.id.form_layout);
FormFiller.using(mForm) //create a filler using a specific Form Entity (mForm)
/*setFillAccessibleOnly spécify if you want to flow enabled view Only
(desabled view and not fowussable view would be ignored.)*/
.setFillAccessibleOnly(false)
.fillWith(mFormView); //fill the form with view values.
Documentation in progress... :-)
Documentation in progress... :-)
Just add the dependency to your build.gradle
:
dependencies {
implementation 'istat.android.freedev.forms:istat-zformx:1.1.4'
}
All available public versions are:
- 1.0.0
- 1.1.0
- 1.1.0
- 1.1.2
- 1.1.3
- 1.1.4
- 1.1.5
Library is compatible with Android 2.3 and newer.
add the dependency to your pom.xml:
<dependency>
<groupId>istat.android.freedev.forms</groupId>
<artifactId>istat-zformx</artifactId>
<version>1.1.4</version>
<type>pom</type>
</dependency>