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 :)
Use this online tool:
http://www.buzzingandroid.com/tools/android-layout-finder/
It simply gets the job done quickly. I use it every day.
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!
There is an Eclipse plugin that does exactly what you want , I guess: http://marketplace.eclipse.org/content/lazy-android
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With