View on GitHub

Android-codegenerator-plugin-intellij

Intellij Plugin for Android code generation.

Download this project as a .zip file Download this project as a tar.gz file

Introduction

Android Code Generator Plugin for Android Studio/IntelliJ IDEA was created to accelerate the process of creating or developing Android applications. Every Activity needs to have XML layout, and Activity contains all the wiring up code like:

Instead of writing this code, I would be great if this code could be generated automatically. This way I come up with idea to have a plugin which does the code generation. I couldn't find such plugin so I decided to write it by myself. Luckily I was off project then, and I could spend some time on it. This way I created the first version in 2011. In 2014 I decided to basically rewrite the plugin from the beginning, add tests and split it into two projects:

Install from JetBrains repository

You can install plugin from repository: Preferences/Settings->Plugins->Browse repositories... Then type in search: Android code Generator

Download and install

All available versions of plugin are in releases. You can download zip file from latest release and install it.

How does it work

Plugin is retrieving from xml files, data about all the views that contain android:id attribute. It collects informations about view's type and id. Based on the type of object and id plugin generates fields, assignment, imports and methods. For more informations go to android-codegenerator-library project.

How to use it

Finding menu options

For all xml files that are either in layout or menu directories menu option Generate Android Code appears. You can invoke it from Project Explorer as well as from Editor.

Menu Options

Generating Activity

Generating Activity

Generating Menu for Activity

Generating Menu

Modifying code to generate

Plugin settings in Preferences

Features

There are several very useful features some of them are:

Plans for future

Improving plugin usability.

Authors and Contributors

The author is Tomasz Morcinek @tmorcinek.

Support or Contact

If you have any problems with the plugin, or want to help, please contact me: tomasz.morcinek@gmail.com and I will try to reply as soon as I can.