2

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.

Brian Diggs
  • 57,757
  • 13
  • 166
  • 188
rags
  • 21
  • 1
  • 1
  • 3

3 Answers3

7

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

Muhammad Shahab
  • 4,187
  • 4
  • 34
  • 44
1

There is also the include route:

Community
  • 1
  • 1
dave.c
  • 10,910
  • 5
  • 39
  • 62
  • By using include, do we not have to write the code in every activity to perform functions on menu click? – rags Apr 05 '11 at 07:41
  • 1
    You could write a base `Activity` class that contains all your common menu code, then each unique `Activity` extends the base class. – dave.c Apr 05 '11 at 07:48
0

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.

Community
  • 1
  • 1
Peter Knego
  • 79,991
  • 11
  • 123
  • 154
  • thanks peter, actually i want to perform some database operation in every page, thats why i made use of activities with every layout xml. – rags Apr 05 '11 at 07:38
  • 1
    Why do you need Activities to do database operations? In any case you should not execute long-running tasks on UI thread. – Peter Knego Apr 05 '11 at 09:07