Member-only story

Android: The Absolute Beginners Guide To Data Binding (Videos Included)

Joseph Howerton
4 min readMay 7, 2021

--

If you haven’t read The Absolute Beginners Guide To View Binding, I recommend doing so. Okay, let’s get on with it.

Table Of Contents

Setup

  • Enable Data Binding
  • Apply Kotlin Kapt Plugin
  • Add Data
  • Add <layout> Tag
  • Add <data> & <variable> Tag
  • Bind Data In XML Layout

Activity

  • Create Activity Binding Class
  • Set Content View
  • Bind Data In Code

Fragment

  • Inflate Fragment Binding Class
  • Return Binding Object Root View
  • Bind Data In Code

Implementation First, Explanation Later

Enable Data Binding

Locate the app-level Gradle file and enable the data binding support library.

buildFeatures{    dataBinding = true}

Apply Kotlin Kapt Plugin

Also, in the app-level Gradle file, apply the kotlin-kapt plugin.

--

--

No responses yet