There’s no place where Eclipse-Databinding doesn’t work

Tonight I thought I’ll give Android a spin, I download the sources and worked through some samples. After an hour this got boring and because I already managed to get Eclipse-Databinding working in other Environments (GWT, Swing, QT) I thought now it is time to see if I can manage to get a minimal example working on Android.
Here’s the application:

The model code looks like this (I’m using UBeans here because they are completely self contained and have no dependencies)

private static class Person extends UBean {
  public static final int NAME = 1;

  public String getName() {
   return (String) get(NAME);

  public void setName(String name) {
   set(NAME, name);

  public Object getValueType(int featureId) {
   return String.class;

The UI-Code looks like this (fairly straight forward UI-Code):

TextView view = new TextView(this);
view.setText("Name: ");
TableLayout layout = new TableLayout(this);

EditText text = new EditText(this);

Button button = new Button(this);
button.setText("Say Hello");
button.setOnClickListener(new OnClickListener() {
   public void onClick(View v) {
    Dialog dialog = new Dialog(Test.this);
    dialog.setTitle("Hello " + p.getName() + "!");;

And now the important thing how do we connect UI and Model-Attributes? Right we use Eclipse-Databinding (well not the one you get from Eclipse directly because it doesn’t compile out of the box but patching it took about 30 minutes :-).

IObservableValue mObs = UBeansObservables.observeValue(realm, p, Person.NAME);
IObservableValue uiObs = AndroidObservables.observeText(realm, text);
DataBindingContext ctx = new DataBindingContext(realm);
ctx.bindValue(uiObs, mObs, null, null);

Cool isn’t it? Would a Eclipse-Databinding port for Android help you? Then take a look at the newly proposed Eclipse-Project UFacekit. We already provide Viewer and UI-Observable implementations for different Platforms (SWT,Swing,QT) and plan to provide one for other platforms (GWT, Eclipse-Forms, … you name it). Why should we not provide them for Android-Widgets too?

This entry was posted in Databinding. Bookmark the permalink.

3 Responses to There’s no place where Eclipse-Databinding doesn’t work

  1. Daniel says:

    It would be great to have databinding for android widgets!

  2. Pingback: Eclipse Data Binding for Android | PartMaster

  3. Pingback: Eclipse Data Binding für Android | PartMaster

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.