java - How to extend an activity from the MainActivity class file? -
the ui elements in mainactivity class need preserved , other class file adds new ui element main xml layout that's used both classes differing degrees.
it's understood can create base abstract class , 2 concrete inherited classes in case there third supporting class second (other class) , requires handler function.
for perspective, button (in activity_main) clicked , should launch activity while maintaining ui elements used mainactivity. furthermore button has it's own class file methods , isn't in mainactivity.
what happens now? button pressed , nothing happens. manifest confirmed not that. or allow main activity or other activity , works, both need work simultaneously.
basically mainactivity needs act base abstract activity separate class file.
you messing activities , views. reuse same business logic, can write common logic in base class other activities (i.e. class baseactivity extends activity). reuse different ui parts should either use fragments or can use <include>/<merge> tags pair include layout layout.
Comments
Post a Comment