问题
I want to have an static bottom menu bar exist through out the applications in every page visible at bottom all the time. I have designed the menu bar but i am confused whether i have to integrate the menu code with every layout xmls to make menu visible in every page and write the code in every activity class to perform functions on menu clicks. Or if there is any other way i can create a common bottom bar that lies with every page with writing the code of menu in a single activity class.
回答1:
Well the best way in my opinion , is to create a bottom bar xml file , and include it in every Activity's xml file
<include android:layout_width="fill_parent" layout="@layout/bottom_bar" />
where your bottom bar xml file name is bottom_bar.xml
This article also might help you
http://android-developers.blogspot.com/2009/02/android-layout-tricks-2-reusing-layouts.html
回答2:
There is also the include
route:
- Common layout in all tabs
回答3:
What you are probably looking for is one Activity with a TabBar with tabs at the top and buttons at the bottom: Android: Tabs at the BOTTOM
Then you can use different Views that correspond to Tabs instead of separate Activities.
来源:https://stackoverflow.com/questions/5548554/android-creating-bottom-bar-menu