kotlin Data Binding in Android

kotlin data binding

What is Data Binding?

Data Binding is very good coding pattern for minimizing application source.here we will learn kotlin data binding in android. it gives you a facility to communicates between your view and model. It keeps code clean and sort.

Hello friends, in this tutorial I will explain Data binding android with kotlin. if you are new for kotlin then please refer post Get started with kotlin, Basics of Kotlin & Kotlin Operations

Assume that you are aware of mobile development.

let’s started with the tutorial

Kotlin Data Binding in Android

  • Create New project

Please follow step for creating a project with kotlin here.

Add Data Binding kotlin dependency in project.gradle file

In application build.gradle file apply plugin

Your build.gradle will be like

Now next step is to

  • Create Data Model

I have created DataBindingKotlinModel.kt

Use this model in your activity layout file.

  • Create Layout

activity_main.xml

  • Use Data Model In Activity

Now Use data model to bind some data with layout in your main activity

MainActivity.kt

Let’s test it. run it you will get output as given below.

 

Next Tutorial Data Binding With Fragment >

Hope you enjoy this tutorial. If you like this post then you can share this blog.

Subscibe for more post of kotlin

796total visits,16visits today

Related posts

Leave a Comment