general menu for all layout android

i have a photo sharing apps which display bottom menu in all layout i have create one but is display when i press menu key i want menu which display when any activity start so how can i create general menu for all layout and no need to press menu key for display bottom menu bar android thanks

menu.xml
<?xml version="1.0" encoding="utf-8"?>

<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item android:id="@+id/menu_bookmark"
      android:icon="@drawable/icon_bookmark"
      android:title="Bookmark" />

<item android:id="@+id/menu_share"
      android:icon="@drawable/icon_share"
      android:title="Share" />

<item android:id="@+id/menu_delete"
      android:icon="@drawable/icon_delete"
      android:title="Delete" /> 


</menu>

activity.java

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.layout.menu, menu);
    return true;
}

Answers


Instead of creating Menu you have to make a common custom xml layout for your menu and include it with your all activity's layout xml file. For this you can use <merge> and <include> tag of Android XML Layout.

Look at Layout Tricks: Merging Layouts

Layout Tricks: Creating Reusable UI Components

Update:

Now on your question, To open a Menu without pressing Menu Button, you can put this line in your onCreate() of Activity.

openOptionsMenu();

And to close:

closeOptionsMenu();

These both methods for Activity class, So if you are using it out-side of activity then use context of Activity and with this method.


Need Your Help

Something better than .ToArray() to force enumeration of LINQ output

c# linq .net-3.5

I'm working with LINQ to objects and have a function where in some cases I need to modify the underlying collection before calling Aggregate(...) and then return it to its original state before the

Play 2.0 vs. Play 1.2.5-RC1 + CRUD + Other Modules

java playframework playframework-2.0 playframework-1.x

I've been asking and investigating around about the new Play Framework 2.0. It seems like a great tool to create websites with Java. It high quality framework I must say.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.