DataBinding templates for Android Studio?
Asked Answered
P

5

5

I've decided to use DataBinding library for my Android project. Are there any plugins/code templates available to install into Android Studio to get new Activity / Fragment etc added using Android Studio's wizard auto generated code compatible with DataBinding? I need to create models/presenters/variables in xml every time, can I get them to be generated automatically?

Parttime answered 3/7, 2017 at 14:51 Comment(0)
C
9

you can ALT + Enter on your view root then convert into databinding layout .

Commentator answered 2/3, 2020 at 9:33 Comment(1)
Window: ALT + Enter and MacOS : Option + Enter.Errant
E
4

Go to build.gradle of your module and enter

android {
    ...
    buildFeatures {
        dataBinding true
    }
}

and then ALT + Enter on your view root and select convert into databinding layout .

Elective answered 25/3, 2021 at 18:19 Comment(0)
P
3

Well,it's not fully what am I looking for, but this looks promising: https://plugins.jetbrains.com/plugin/9271-databinding-support - int theory, it should able to convert standard layouts to data binding:

enter image description here

enter image description here

It basically intended to add all mising DataBinding integration to Android Studio. Shame Google is still not going to add any databinding integration to Android Studio and we need 3rd party plugins for that.

Parttime answered 7/7, 2017 at 6:17 Comment(0)
S
0

You should customize templates and put it into the <Android Studio Installation path>\plugins\android\lib\templates folder.

Samalla answered 19/4, 2018 at 5:29 Comment(0)
E
0

Android Studio Shortcut:

Step 1: place a cursor at view root (means top most view).

Step 2:

For Window: Alt + Enter

For MacOs : Option + Enter

Step 3: Select convert into databinding layout

Step 4: Clean and rebuild

Errant answered 6/8, 2023 at 17:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.