Raja Jawahar
Raja Jawahar

Reputation: 6962

How can I reduce the reference line for widgets in Android?

I have a project with more than 50 plus layouts, for each one I am doing codes for getting the reference of the widgets like findViewById. Is there anyway to reduce the lines.

Upvotes: 1

Views: 78

Answers (2)

Bharatesh
Bharatesh

Reputation: 9009

Android introduced Data Binding Library to get rid of findViewById(); visit Android Official : Data Binding Guide.

Important : Its in Beta Version.

Updated: Now its available in Alpha

Upvotes: 3

Michal Harakal
Michal Harakal

Reputation: 1035

I would recommend to use Butterknife.

Because it uses annotation processing during compilation, there is no performance/overhead penalty during a runtime.

As a tip, don't forget put ButterKnife.inject(this); in a proper place like onCreate()

Upvotes: 3

Related Questions