what I am trying to do is to show a menu bar at any time no matter what layout or Activity is being displayed. What I’m basically doing is create an activity (lets call it MenuActivity), that creates the buttons, and make the other activities extend from MenuActivity. The problem is, I cant find a way to make the buttons get displayed on the other activities. Here is the xml of the buttos if this helps:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/relativeLayout" >
<Button
android:id="@+id/ABC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="14dp"
android:layout_y="373dp"
android:text="@string/abc" />
<Button
android:id="@+id/favoritos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="62dp"
android:layout_y="374dp"
android:text="@string/favoritos" />
<Button
android:id="@+id/Cupones"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="243dp"
android:layout_y="372dp"
android:text="@string/cupones" />
<Button
android:id="@+id/destacados"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="145dp"
android:layout_y="375dp"
android:text="@string/destacados" />
</AbsoluteLayout>
Thanks in advance!
I guess that your problem will be solved if you
includethis layout aschild layoutin layout of other Activities:The menulayout.xml is name of your above layout that should be defined in
res/layoutand you like that be shown as menu in all Activities,alsomenuLayoutis id of your menulayout and you can reference to it in your Activity’s layout or in your code.You can override all the layout parameters. This means that any android:layout_* attribute can be used with the
<include />tag. Here is an example:You can see more details in about include in this page.
Edit:
If you have problems in about finding views in included layout,see this questions,I hope these help you:
findViewById not working for an include?
Finding an view by id?