Question

I would love to get all the features lombok provides. I'm tired of writing lots of boilerplate code and I would like to know if there is a port of lombok on Android? Or at least an equivalent? Something that allows me to use an annotation instead of boilerplate like this:

TextView tv = (TextView) findViewById(R.id.my_textview);
Était-ce utile?

La solution

As far as I know you can use Lombok in Android code. If it doesn't, please file a bug report. I must say, we don't have a lot of documentation about how to set it up. That said, we have an active mailing list if you need help. Disclosure: I am one of the developers of Lombok.

Autres conseils

As an alternative, have a look at Android Annotations.

I was under the impression that Lombok just creates Java, so have you tried it? (I haven't, but just curious). However, as far as getting rid of the findViewById type of boilerplate you can take a look at RoboGuice. It does a whole lot more, but one of the niceties it adds is changing something like:

TextView tv = (TextView) findViewById(R.id.my_textview);

to:

@InjectView(R.id.my_textview)
TextView tv;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top