General constant menu in the application

2019-07-22 11:21发布

问题:

I'm developing an Android application that has 10 different activities with the same constant menu at the bottom of their screen. Is fragments is the best way to build the menu or just build a base activity class that all the activities inherits from it?

thanks.

回答1:

You should create a class let say MyBaseActivity that extends Activity and in that class take care of displaying that menu etc.

Then you should let all your Activities in your application extend your custom MyBaseActivity.



回答2:

It depends on how the bottom line should behave on activity changes. If you want it not to move, you habe to use fragments. For pre-Honeycomb devices you'll need the Android Compatibility package provided in the SDK.

If you don't care that the bottom line will be destroyed and recreated on every change of activity, your way to go is as Ovidiu Latcu wrote extending a BaseActivity which provides just the bottom line.