146 Java Android Program to Demonstrate Creating an Options Menu in Android
Posted by Superadmin on December 06 2015 15:41:44
Here is source code of the Program to Demonstrate Creating an Options Menu in Android. The program is successfully compiled and run on a Windows system using Eclipse Ide. The program output is also shown below.
Main Activity
package com.example.options_menu;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(1, 1, 0, "Item1");
menu.add(1, 2, 1, "Item2");
menu.add(1, 3, 2, "Item3");
menu.add(1, 4, 3, "Item4");
menu.add(1, 5, 4, "Item5");
return true;
}
}