Android data binding — 4

Sample form data binding

In this section, we gather all things in previous sections into one demo.

Demo includes:

  1. User compose message included: receiver email & message content
  2. User has to fulfill the form
  3. Receiver email have to be in right format. UI shows that email is correct or not
  4. UI form also counts number of message characters

Check out source code at: https://github.com/rickyngk/android-data-binding-example/tree/master/sample4


Some highlight points in this demo

1. Pass view-model into child layout (when using <include>)

2. Get element via ID using binding object

3. Hide/show element using binding expression

See Binding Expression document for more detail


TOC

Part 1: Binding static value

Part 2: Binding user event

Part 3: EditText & Two-way data binding

Part 4: Sample form data binding