About

The forms project simplifies the composition of forms in Android applications.

A form consists of one or more sections with section headers. Each section can hold one or more section entries. These entries are either only viewing data or for editing data. There are methods for each type (view and edit).

Usage

There is no special container or layout for the form so you can just use a normal Linearlayout with a vertical orientation. Now we are adding sections to this layout.

			// get the linear layout
			ViewGroup mainLayout = (ViewGroup) findViewById(R.id.forms_layout);
		

Now we are adding a section to this layout.

			ViewGroup sectionInnerLayout = Forms.addSection("Common", mainLayout, inflater);
		

We are also adding some fields to this section. Notice that we now pass the previously returned ViewGroup sectionInnerLayout to the Forms factory method.

			Forms.addSectionEntry("LASTNAME", employee.getLastName(), sectionInnerLayout, inflater);
			Forms.addSectionEntry("FIRSTNAME", employee.getFirstName(), sectionInnerLayout, inflater);
		

There is also a method that adds a button right next to the data. We just have to pass the image and the OnClickListener to the method and also a tag object so we can easily identify which entry has triggered the onClick Event.

	Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_mail);
	Forms.addSectionActionEntry("EMAIL", employee.getEmail(), sectionInnerLayout, icon, inflater, this, 
			Tag.email, "write email");
		

Requirements

This Android library works from API level 11 upwards (Android 3.x).

License

This software is released under the BSD 2-Clause License.

Download

A demo APK showing a forms example can be found in the projects files section. The permission INTERNET is needed to run the demo because the Solr example needs network access to the remote Solr server instance.

Source Code

The source code can be fetched from Sourceforge.net with the following command

hg clone http://hg.code.sf.net/p/andless/forms forms