I am doing menu item. But i am not able to view the menu item in the screen. Can anybody tell me what is getting wrong or what other need to be added to get the code working. I have got totally stuck.
package com.example.androiddemo;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
public class MenuItem extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.menu.menupage);
}
public boolean onCreateOptionsMenu(Menu menu){
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menupage, menu);
return true;
}
}
xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/about"
android:icon="@drawable/images"
android:title="About"
android:showAsAction="ifRoom"
/>
<item
android:id="@+id/setting"
android:icon="@drawable/ic_launcher"
android:title="App Setting"
/>
</menu>
Here you have to set your activity’s xml file.
After running this, just press on menu, It should show your options. If not post back.