General constant menu in the application

2019-07-22 10:59发布

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.

2条回答
你好瞎i
2楼-- · 2019-07-22 11:52

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.

查看更多
时光不老,我们不散
3楼-- · 2019-07-22 11:52

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.

查看更多
登录 后发表回答