{"id":1532,"date":"2018-01-12T09:54:38","date_gmt":"2018-01-12T09:54:38","guid":{"rendered":"https:\/\/www.moveoapps.com\/blog\/?p=1532"},"modified":"2019-09-25T11:25:15","modified_gmt":"2019-09-25T11:25:15","slug":"how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide","status":"publish","type":"post","link":"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/","title":{"rendered":"How to Use Data Binding Library with Kotlin &#8211; A Step By Step Guide"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">For a long time now, Java has been the official language for developing Android applications and we have been using Data Binding Library to bind application logic and layouts. Data binding offers flexibility as well as broad compatibility to your code.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It\u2019s a library that allows you to bind the data of your models directly to the xml views in a very flexible way.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Kotlin was recently introduced as a secondary \u2018official\u2019 Java language. It is similar to Java in many ways but is a little easier to learn and get to grips with. Some of the biggest companies have adopted Kotlin and seen amazing results.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Pinterest, with its 150 million subscribers has <\/span><a href=\"https:\/\/www.youtube.com\/watch?v=mDpnc45WwlI\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">successfully adopted Kotlin.<\/span><\/a><\/li>\n<li><span style=\"font-weight: 400;\">Basecamp says that they have seen a massive improvement in speed, performance and developer happiness after making their<\/span><a href=\"https:\/\/m.signalvnoise.com\/how-we-made-basecamp-3s-android-app-100-kotlin-35e4e1c0ef12\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\"> Android app 100% Kotlin.<\/span><\/a><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">So now, developers who have worked with both Java and Data binding library have a few doubts about whether Kotlin supports Data Binding Library or not? So the answer is YES, Kotlin very much supports Data Binding Library. We can still bind our layouts with the Kotlin class.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In this post, we will learn<\/span><span style=\"font-weight: 400;\"> Kotlin with data binding <\/span><span style=\"font-weight: 400;\">in Android. It gives you the ability to communicate between your view and model. It keeps the code clean and sorted.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">I will show you the approach I used to mix the power of Data Binding with Kotlin with a simple example.<\/span><\/p>\n<p><b>If you want to use data binding and Kotlin, here are a few things to keep in mind:<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Data <\/span> <span style=\"font-weight: 400;\">binding is a support library, so it can be used with all Android platform versions all the way back to <\/span><b>Android 2.1 <\/b><span style=\"font-weight: 400;\">(API <\/span> <span style=\"font-weight: 400;\">level 7+).<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">To use data binding, you need Android Plugin for Gradle <\/span><b>1.5.0-alpha1<\/b><span style=\"font-weight: 400;\"> or <\/span> <span style=\"font-weight: 400;\">higher. You can see here how to <\/span><a href=\"https:\/\/developer.android.com\/studio\/releases\/gradle-plugin.html#updating-plugin\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">update the Android Plugin for Gradle<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/li>\n<\/ul>\n<ul>\n<li style=\"font-weight: 400;\"><a href=\"https:\/\/developer.android.com\/studio\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Android Studio 3.0 <\/span><span style=\"font-weight: 400;\">fully supports kotlin<\/span><\/a><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">First of all, create an Android Studio project and add a dependency for Kotlin and few changes for your Project level build.gradle<\/span><\/p>\n<pre>\u00a0\r\nbuildscript {\r\next.kotlin_version = '1.2.10'\r\next.gradle_version = '3.0.1'\r\n\r\n\r\ndependencies {\r\n\tclasspath \"com.android.tools.build:gradle:$gradle_version\"\r\n\tclasspath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\"\r\n\tclasspath \"org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version\"\r\n\r\n\t}\r\n}\r\n\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">We also need to add the Data Binding dependency and the ones of Kotlin to the build.gradle file of our app.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">apply plugin: 'kotlin-android' \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span>\r\n<span style=\"font-weight: 400;\">apply plugin: 'kotlin-kapt'<\/span>\r\n\r\n<span style=\"font-weight: 400;\">android {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">....<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">dataBinding {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">enabled = true<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">}<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n<span style=\"font-weight: 400;\">dependencies {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">...<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">kapt \"com.android.databinding:compiler:$<\/span><span style=\"font-weight: 400;\">gradle_version\"<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><b>\/\/<\/b><b>Notice that I made the compiler version a variable in the project level build gradle so it can be managed from a single place<\/b><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-weight: 400;\">That\u2019s all the configuration we need to start using Data Binding with Kotlin.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Now for Kotlin and Data Binding to work together, add a Kotlin Model Class. This model class is going to bind your layout with your Kotlin activity class.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">I have created <\/span><b><i>UserModel.kt<\/i><\/b> <span style=\"font-weight: 400;\">class :<\/span><\/p>\n<pre>package com.ktdemo\r\n\r\n<span style=\"font-weight: 400;\">\/*<\/span>\r\n<span style=\"font-weight: 400;\">* Created By Androidian on 29\/12\/17<\/span>\r\n<span style=\"font-weight: 400;\">*\/<\/span>\r\n<span style=\"font-weight: 400;\">class UserModel {<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0lateinit var uName : String<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0lateinit var pwd : String<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Now we use <\/span><b><i>UserModel.kt<\/i><\/b><span style=\"font-weight: 400;\"> model with our layout <\/span><b><i>activity_main.xml<\/i><\/b><\/p>\n<pre><span style=\"font-weight: 400;\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">&lt;layout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"&gt;<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&lt;data&gt;<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&lt;variable<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">name=\"userModel\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">type=\"com.ktdemo.UserModel\" \/&gt;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&lt;\/data&gt;<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&lt;android.support.constraint.ConstraintLayout<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:layout_width=\"match_parent\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:layout_height=\"match_parent\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:padding=\"8dp\"&gt;<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&lt;EditText<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:id=\"@+id\/edtUserName\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:layout_width=\"match_parent\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:layout_height=\"wrap_content\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:layout_marginBottom=\"8dp\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:layout_marginTop=\"8dp\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:hint=\"User Name\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:inputType=\"textPersonName\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:text=\"@={userModel.UName}\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">app:layout_constraintBottom_toBottomOf=\"parent\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">app:layout_constraintEnd_toEndOf=\"parent\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">app:layout_constraintStart_toStartOf=\"parent\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">app:layout_constraintTop_toTopOf=\"parent\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">app:layout_constraintVertical_bias=\"0.4\" \/&gt;<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&lt;EditText<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:id=\"@+id\/edtPassword\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:layout_width=\"match_parent\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:layout_height=\"wrap_content\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:layout_marginTop=\"8dp\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:hint=\"Password\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:inputType=\"textPassword\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">android:text=\"@={userModel.pwd}\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">app:layout_constraintEnd_toEndOf=\"parent\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">app:layout_constraintStart_toStartOf=\"parent\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">app:layout_constraintTop_toBottomOf=\"@+id\/edtUserName\"\/&gt;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">&lt;\/android.support.constraint.ConstraintLayout&gt;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">&lt;\/layout&gt;<\/span>\r\n\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">Now it\u2019s time to bind your <\/span><b><i>MainActivity.kt<\/i><\/b><span style=\"font-weight: 400;\"> class with your layout <\/span><b><i>activity_main.xml<\/i><\/b><span style=\"font-weight: 400;\"> using <\/span><b><i>UserModel.kt<\/i><\/b><span style=\"font-weight: 400;\"> model.<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">package com.ktdemo<\/span>\r\n\r\n<span style=\"font-weight: 400;\">import android.databinding.DataBindingUtil<\/span>\r\n<span style=\"font-weight: 400;\">import android.support.v7.app.AppCompatActivity<\/span>\r\n<span style=\"font-weight: 400;\">import android.os.Bundle<\/span>\r\n<span style=\"font-weight: 400;\">import com.ktdemo.databinding.ActivityMainBinding<\/span>\r\n\r\n<span style=\"font-weight: 400;\">class MainActivity : AppCompatActivity() {<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">lateinit var mainBinding : ActivityMainBinding<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">override fun onCreate(savedInstanceState: Bundle?) {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">super.onCreate(savedInstanceState)<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">mainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main)<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">var userModel = UserModel()<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">userModel.uName = \"Androidian\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">userModel.pwd = \"123456\"<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">mainBinding.userModel = userModel<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span><span style=\"font-weight: 400;\">}<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n<\/pre>\n<p><span style=\"font-weight: 400;\">Time to test it. Run it and you should see an output like this:<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Output<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1547 size-full\" src=\"https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2018\/01\/output.png\" alt=\"\" width=\"321\" height=\"548\" srcset=\"https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2018\/01\/output.png 321w, https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2018\/01\/output-176x300.png 176w, https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2018\/01\/output-88x150.png 88w\" sizes=\"auto, (max-width: 321px) 100vw, 321px\" \/><\/p>\n<p><b>Conclusion <\/b><\/p>\n<p><span style=\"font-weight: 400;\">Kotlin happens to be a great language for coding Android apps and it has been widely appreciated by developers worldwide. So if you have been wanting to get started with it but were apprehensive about it\u2019s Data Binding support, this post should have dispelled your doubts. Go ahead, try Kotlin today and do share your experiences with me. Happy coding everyone!<\/span><br \/>\n<script type=\"text\/javascript\" src=\"\/\/newsharecounts.s3-us-west-2.amazonaws.com\/nsc.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>For a long time now, Java has been the official language for developing Android applications and we have been using Data Binding Library to bind application logic and layouts. Data binding offers flexibility as well as broad compatibility to your code. It\u2019s a library that allows you to bind the data of your models directly &hellip; <a href=\"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to Use Data Binding Library with Kotlin &#8211; A Step By Step Guide<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":101026,"featured_media":1549,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[31],"tags":[],"class_list":["post-1532","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Use Data Binding Library with Kotlin - A Step By Step Guide<\/title>\n<meta name=\"description\" content=\"Data binding offers flexibility as well as broad compatibility to your code.Kotlin was recently introduced as a secondary \u2018official\u2019 Java language\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use Data Binding Library with Kotlin - A Step By Step Guide\" \/>\n<meta property=\"og:description\" content=\"Data binding offers flexibility as well as broad compatibility to your code.Kotlin was recently introduced as a secondary \u2018official\u2019 Java language\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/\" \/>\n<meta property=\"og:site_name\" content=\"Moveo Apps\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-12T09:54:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-09-25T11:25:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2018\/01\/How-to-Use-Data-Binding-Library-with-Kotlin-A-Step-By-Step-Guide.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1294\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Darshan Shah\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Darshan Shah\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/\",\"url\":\"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/\",\"name\":\"How to Use Data Binding Library with Kotlin - A Step By Step Guide\",\"isPartOf\":{\"@id\":\"https:\/\/www.moveoapps.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2018\/01\/How-to-Use-Data-Binding-Library-with-Kotlin-A-Step-By-Step-Guide.png\",\"datePublished\":\"2018-01-12T09:54:38+00:00\",\"dateModified\":\"2019-09-25T11:25:15+00:00\",\"author\":{\"@id\":\"https:\/\/www.moveoapps.com\/blog\/#\/schema\/person\/f526997c29a0290495dfa08c7e3c8cef\"},\"description\":\"Data binding offers flexibility as well as broad compatibility to your code.Kotlin was recently introduced as a secondary \u2018official\u2019 Java language\",\"breadcrumb\":{\"@id\":\"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/#primaryimage\",\"url\":\"https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2018\/01\/How-to-Use-Data-Binding-Library-with-Kotlin-A-Step-By-Step-Guide.png\",\"contentUrl\":\"https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2018\/01\/How-to-Use-Data-Binding-Library-with-Kotlin-A-Step-By-Step-Guide.png\",\"width\":2560,\"height\":1294},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.moveoapps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Use Data Binding Library with Kotlin &#8211; A Step By Step Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.moveoapps.com\/blog\/#website\",\"url\":\"https:\/\/www.moveoapps.com\/blog\/\",\"name\":\"Moveo Apps\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.moveoapps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.moveoapps.com\/blog\/#\/schema\/person\/f526997c29a0290495dfa08c7e3c8cef\",\"name\":\"Darshan Shah\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.moveoapps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2019\/09\/darshan-96x96.jpg\",\"contentUrl\":\"https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2019\/09\/darshan-96x96.jpg\",\"caption\":\"Darshan Shah\"},\"sameAs\":[\"https:\/\/www.moveoapps.com\/\"],\"url\":\"https:\/\/www.moveoapps.com\/blog\/author\/darshan-shah\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Use Data Binding Library with Kotlin - A Step By Step Guide","description":"Data binding offers flexibility as well as broad compatibility to your code.Kotlin was recently introduced as a secondary \u2018official\u2019 Java language","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/","og_locale":"en_US","og_type":"article","og_title":"How to Use Data Binding Library with Kotlin - A Step By Step Guide","og_description":"Data binding offers flexibility as well as broad compatibility to your code.Kotlin was recently introduced as a secondary \u2018official\u2019 Java language","og_url":"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/","og_site_name":"Moveo Apps","article_published_time":"2018-01-12T09:54:38+00:00","article_modified_time":"2019-09-25T11:25:15+00:00","og_image":[{"width":2560,"height":1294,"url":"https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2018\/01\/How-to-Use-Data-Binding-Library-with-Kotlin-A-Step-By-Step-Guide.png","type":"image\/png"}],"author":"Darshan Shah","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Darshan Shah","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/","url":"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/","name":"How to Use Data Binding Library with Kotlin - A Step By Step Guide","isPartOf":{"@id":"https:\/\/www.moveoapps.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/#primaryimage"},"image":{"@id":"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/#primaryimage"},"thumbnailUrl":"https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2018\/01\/How-to-Use-Data-Binding-Library-with-Kotlin-A-Step-By-Step-Guide.png","datePublished":"2018-01-12T09:54:38+00:00","dateModified":"2019-09-25T11:25:15+00:00","author":{"@id":"https:\/\/www.moveoapps.com\/blog\/#\/schema\/person\/f526997c29a0290495dfa08c7e3c8cef"},"description":"Data binding offers flexibility as well as broad compatibility to your code.Kotlin was recently introduced as a secondary \u2018official\u2019 Java language","breadcrumb":{"@id":"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/#primaryimage","url":"https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2018\/01\/How-to-Use-Data-Binding-Library-with-Kotlin-A-Step-By-Step-Guide.png","contentUrl":"https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2018\/01\/How-to-Use-Data-Binding-Library-with-Kotlin-A-Step-By-Step-Guide.png","width":2560,"height":1294},{"@type":"BreadcrumbList","@id":"https:\/\/www.moveoapps.com\/blog\/how-to-use-data-binding-library-with-kotlin-a-step-by-step-guide\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.moveoapps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Use Data Binding Library with Kotlin &#8211; A Step By Step Guide"}]},{"@type":"WebSite","@id":"https:\/\/www.moveoapps.com\/blog\/#website","url":"https:\/\/www.moveoapps.com\/blog\/","name":"Moveo Apps","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.moveoapps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.moveoapps.com\/blog\/#\/schema\/person\/f526997c29a0290495dfa08c7e3c8cef","name":"Darshan Shah","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.moveoapps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2019\/09\/darshan-96x96.jpg","contentUrl":"https:\/\/www.moveoapps.com\/blog\/wp-content\/uploads\/2019\/09\/darshan-96x96.jpg","caption":"Darshan Shah"},"sameAs":["https:\/\/www.moveoapps.com\/"],"url":"https:\/\/www.moveoapps.com\/blog\/author\/darshan-shah\/"}]}},"_links":{"self":[{"href":"https:\/\/www.moveoapps.com\/blog\/wp-json\/wp\/v2\/posts\/1532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.moveoapps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.moveoapps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.moveoapps.com\/blog\/wp-json\/wp\/v2\/users\/101026"}],"replies":[{"embeddable":true,"href":"https:\/\/www.moveoapps.com\/blog\/wp-json\/wp\/v2\/comments?post=1532"}],"version-history":[{"count":19,"href":"https:\/\/www.moveoapps.com\/blog\/wp-json\/wp\/v2\/posts\/1532\/revisions"}],"predecessor-version":[{"id":1554,"href":"https:\/\/www.moveoapps.com\/blog\/wp-json\/wp\/v2\/posts\/1532\/revisions\/1554"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.moveoapps.com\/blog\/wp-json\/wp\/v2\/media\/1549"}],"wp:attachment":[{"href":"https:\/\/www.moveoapps.com\/blog\/wp-json\/wp\/v2\/media?parent=1532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.moveoapps.com\/blog\/wp-json\/wp\/v2\/categories?post=1532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.moveoapps.com\/blog\/wp-json\/wp\/v2\/tags?post=1532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}