Skip to content
svenmeier edited this page Jan 18, 2012 · 9 revisions

Propoid-ui simplifies working with views. The Index allows convenient and performant access to views from your layout:

    Index index = Index.get(this); // 'this' can be activity, dialog or view

    EditText editText = index.get(R.id.edit);

Bind a property to a view with a single line of code:

    TextBinding.string(foo.stringProperty, editText);

All changes to the property are automatically propagated to the view and vice versa.

Text

Converters allow conversion for a TextBinding:

    new TextBinding(foo.intProperty, editText, new NumberConverter(R.string.NO_NUMBER));

Factory methods make it convenient for the following types:

    TextBinding.string(foo.stringProperty, editText);
    TextBinding.number(foo.intProperty, editText);

Conversion errors are automatically reported on the view.

CheckBox

Boolean properties can be bound to CheckBox views view CheckBinding:

    new CheckBinding(foo.booleanProperty, checkBox);

Spinner

Properties can be bound to a spinner via SpinnerBinding:

    new SpinnerBinding(foo.barProperty, spinner, listAdapter);

You don't need to implement your own list adapter though. With a suitable Converter you can conveniently use a list (or varargs) of choices:

    new SpinnerBinding(foo.intProperty, spinner, new NumberConverter(), 100, 200, 300);

Factory methods make it even simpler for the following types:

    SpinnerBinding.string(foo.stringProperty, spinner, "A", "B", "C");
    SpinnerBinding.number(foo.intProperty, spinner, 100, 200, 300);
    SpinnerBinding.enumeration(foo.barProperty, spinner, Bar.values());

Clone this wiki locally