Reputation: 123
Does anyone know of any Eclipse plug-in or anything that can be used to automatically generate Java code from layout file? As in, if I have an EditText in my layout file with the ID "@+id/txtHello", I expect something like the following to be generated:
EditText txtHello = (EditText) findViewById(R.id.txtHello);
Thanks for your time!
Harris :)
Upvotes: 9
Views: 10891
Reputation: 93
There is new plugin that can generate Activity, Fragment, Adapter based on xml layout. Can also generate Menu related code (handling actions) for xml menu files. And has editable templates, so the user has more control on the generated data.
For Eclipse: http://tmorcinek.github.io/android-codegenerator-plugin-eclipse/
For Android Studio/IntelliJ IDEA: http://tmorcinek.github.io/android-codegenerator-plugin-intellij/
Upvotes: 1
Reputation: 15668
Normally there are three different ways to do this:
A good article to start is Clean Code in Android Applications.
Ad 1) Two solutions, see
Ad 2) Android Annotations, see http://androidannotations.org/
Ad 3) Two solutions, see
If there is more, please tell! I personally prefer 2) and therefore Android Annotations.
Hope that helps!
Upvotes: 10
Reputation: 1246
Use this online tool:
http://www.buzzingandroid.com/tools/android-layout-finder/
It simply gets the job done quickly. I use it every day.
Upvotes: 9
Reputation: 69198
There is an Eclipse plugin that does exactly what you want , I guess: http://marketplace.eclipse.org/content/lazy-android
Upvotes: 5