Search code examples
androideclipse-pluginfindviewbyid

Is there an eclipse plugin to generate findViewById calls?


I use eclipse for android development, and I find it very annoying that every time I create an activity or add new views to my activity, I need to create the references to views in my layout. I am looking for some kind of eclipse plugin that can generate the calls to findViewById() from the layout. I couldn't really find anything because I didn't know what it would be named. It would be very useful and time saving if that kind of plugin existed.

EDIT: The answers you gave are great. Can these tools also add more references to an existing activity so I don't have to manually do that when I add a view to the layout?


Solution

  • Try the morcinek code generator. Its really simple to use.

    This are the steps to install the plugin:

    http://tmorcinek.wordpress.com/2011/11/30/eclipse-plugin-for-automatic-generation-of-activity-code-from-xml-layout-file/

    After install process you may want to configurate a package to get the classes built by the generator, on the IDE -> Window -> Preferences on Bookmark Android Code Generator you can change that parameter.

    The plugin does need a better interface for custom activities, still you could get the code, its really simple to make the changes you need, at least the inline listeners.

    This solution doesnt work to modify classes you already have, that would be a really good improvement... i'll give it a try in a couple days with more time.