When we make Android layout in XML, we can use include to make some other layout the part of the host layout. Is there such thing for Java class?
I am attaching a top bar layout to every screen and it contains buttons. Now in every Java class I have to copy/paste the initialization code.
Is there any shortcut for such scenarios? Can Application class facilitate anyhow? If anyone has a working solution, please share it with me.
For example, in XML I can use
//...xml layout elements
<include layout="@layout/topbar" />
//...some other xml layouts
so it would be cool to be able to use in Java code something where I could instantly initiate buttons, register onClick events and set actions to these events. It all the same piece of code I am using, after all.
Make an activity (BaseActivity) with the implementation you desire and just extend this class in your other activities.