-
Notifications
You must be signed in to change notification settings - Fork 4
Binding types
Sasa Sekulic edited this page Mar 30, 2016
·
9 revisions
When creating bindings, you can use different types, so that you make sure that the value isn't changed after you set it - or, on the contrary, is updated whenever you want. There are 5+1 different binding types:
- _Default _("=") i.e. TwoWay ("@=@") - The default binding type is the two-way continuous binding. Whenever either the source or the bound view are updated, the corresponding source/bound view will get updated.
- OneWay ("@=") - One-way continuous updating is used when you want to update views that don't emit any values, like for example TextViews.
- OneWayOneTime ("@-") - One-way one-time means that the bound view will be updated exactly once, when setting the Viewmodel. Make sure that the value is present there. You would probably use this for page titles or TextViews used as labels.
- OneWayToSource ("-@") - as OneWay, but pointing to another direction, from the view to the view model, inverting the data flow. You might use these for EditTexts, Switches, RadioButtons or any other type of input widget that you don't want to be set from code.
- OneWayToSourceOneTime ("=@") - as OneWayOneTime but with the inverted flow, from widget to view model.