Suppose I have 5 different activities, but the layout and functions at the bottom of the 5 activities are the same (other layouts are different, such as toolBar). I would like to ask how to make this same layout only written in the base class Activity Then other activities inherit this BaseActivity, thereby only writing code in one place without writing the same code in other activities.
ps: If this method cannot be achieved, is there any other method?
You can read this article and see what others have done. I hope it will inspire you: http://www.jianshu.com/p/5bab...
/q/10...
This question of yours is similar to the one above. Please refer to it.
First we define a Boolean variable to control whether the common part is displayed, and add the method as follows:
Then we override setContentView in BaseActivity: as follows
Finally, in onCreate() of other subclasses that inherit BaseActivity, we must call the method setShowCommonView (Boolean) defined at the beginning before super.onCreate() to control whether the common part is displayed. As follows