1

I am trying to create a menu in android. But it results only in blank page with text only. Menu is not coming on the screen. code is given below

public class SimpleOptionMenu extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);
    return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.icon:     Toast.makeText(this, "You pressed the icon!", Toast.LENGTH_LONG).show();
                            break;
        case R.id.text:     Toast.makeText(this, "You pressed the text!", Toast.LENGTH_LONG).show();
                            break;
        case R.id.icontext: Toast.makeText(this, "You pressed the icon and text!", Toast.LENGTH_LONG).show();
                            break;
    }
    return true;

} }

please help to solve this problem.

ernazm
  • 9,208
  • 4
  • 44
  • 51
bejoy george
  • 29,385
  • 5
  • 19
  • 15
  • can you show your menu.xml file here, the code was correct – Pratik Jun 29 '11 at 07:58
  • Can you please provide the xml file? The code above looks good. – Mark Jun 29 '11 at 08:00
  • > > > xmlns:android="http://schemas.android.com/apk/res/android"> > android:icon="@drawable/icon" /> > android:title="Text" /> > android:title="Icon and text" > android:icon="@drawable/icon" /> ---- – bejoy george Jun 29 '11 at 09:04

1 Answers1

1

When you will press Menu key on your phone you will see the menu

Sarmad
  • 389
  • 2
  • 8