Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 126.96.36.199 release ready!
Owner and Founder. Opencart
With the relaese of android M , the data binding came into android. As its a support library it supports back to API level 7. The data binding is a technique to bind the application logic to the layouts which was earlier a redundant work. You have to initialize the view using findViewById() and then you have to set the value for the view.
But with data binding you can bind your data directly to the xml without initializing them to variables. So here we will make a Sample project to understand data binding.
Firstly we have to support the binding, to do so add these lines of code to your project level gradle
now add plugin to your app level gradle
Now your project is ready to support databinding. So lets start binding the data to our layout.
Suppose we want a layout to show a person data having name, age , phone number, email etc. For this we are having a Person class as
So the binded layout activity_main.xml will be like
With this xml file, the system will generate a Binding class with converting the xml name in Pascal case and suffixing Binding in it. As our xml name is activity_main so the binding class wil be named ActivityMainBinding.
Lets inflate the xml and get our data as required
Initially it will show an error(red mark) but once project build is done it will work as expected. Basically data binding reduces the redundant and non logical code. You can use databinding with listview and recycler view as well and the places where you are inflating a single xml again and again. But we will discuss it later.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.