简体   繁体   中英

How to Enable DataBinding by default for new projects

is there any way to enable Data Binding by default for new project and also new activity or fragment we create? I HOPE?!!

any advice you could give would be much appreciated.Thank You.

To enable Data Binding by default for new projects in Android, you can create a template project that includes Data Binding and then use it as a starting point for new projects. Here are the steps:

Create a new Android project with Data Binding enabled:

  • In Android Studio, select File > New > New Project.
  • In the Create New Project wizard, select the settings you want and
    then click the Next button.
  • In the Target Android Devices wizard, select the settings you want and then click the Next button.
  • In the Add an Activity to Mobile wizard, select Empty Activity and then click the Next button.
  • In the Configure Activity wizard, select Data Binding and then click the Finish button.
  • Copy the generated layout file and the Java code file for the MainActivity class to a new folder.
  • Go to File > Project Structure > Project Settings > Project and set the "Project compile sdk version" to the latest version available.
  • Go to File > Project Structure > Project Settings > Modules and set the "Data Binding Library version" to the latest version available.
  • Save the project as a template by going to File > Export Template.
  • Import the template into Android Studio by going to File > New > Import Project.
  • Use the template as a starting point for new projects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM