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; } }
Sanfoundry Global Education & Learning Series – 100+ Java Android Tutorials.
If you wish to look at all Tutorials, go to Java Android Tutorials.
Related Posts:
- Check Programming Books
- Practice BCA MCQs
- Apply for Computer Science Internship
- Apply for Java Internship
- Practice Information Technology MCQs