Presentation is loading. Please wait.

Presentation is loading. Please wait.

Android UG - #15 Agenda: Android news from the last month

Similar presentations


Presentation on theme: "Android UG - #15 Agenda: Android news from the last month"— Presentation transcript:

1 Android UG - #15 Agenda: Android news from the last month
Introduction to Data Binding in Android

2 Android happenings in Feb/Mar
Android N – Early release New Hangouts launched RetroFit 2.0 is released Destinations on Google launched

3 Android N OTA distribution
Only for modern Nexus devices currently (Nexus 6, Nexus 5X, Nexus 6P, Nexus Player, Nexus 9, and Pixel C devices + emulator with N SDK) Split screen function Bundled and direct reply notifications More memory/efficiency improvements via Doze Improved Java 8 support via Android’s Jack compiler– giving us access to lambdas etc Join up here : g.co/androidbeta

4 Data Binding and what we do now
What is Data Binding? In its simplest form Data Binding provides a mechanism to connect UI elements directly with their datasource – generally cutting out the middlemen (Activities) that are used currently to set values on the elements How do we code now? Standard Android way is to lookup views with findViewById(int) There are libraries that can help roboguice / dagger / butterknife Pros Well used and recognised patterns Explicit – easier to see where you are setting data and where events are coming from Cons Verbose your Activity becomes swollen with simple calls

5 Data Binding – what we do now
findViewById is not the fastest call … and not great when you have lots of UI elements Using Data Binding … Helps clarify the role of Activity in MVVM (Model-View-ViewModel) pattern? Far less UI manipulation code in the Activity

6 Data Binding – Getting started
Support Lib installed – download through the SDK manager (v23.2 currently) Gradle alpha1 Android Studio ( I used 2.0 beta 6.0) Add the below to your build.gradle: android { .... dataBinding { enabled = true }

7 Data Binding – basic example
Change your layout root Introduce a <data> element Connect your widgets to the data Connect the binding in the Activity

8 Data Binding – More Reading
RecyclerView examples Simple: More Complex lists: Two way data


Download ppt "Android UG - #15 Agenda: Android news from the last month"

Similar presentations


Ads by Google