Here i wrote some code but not getting output..
Please tell me why is not displaying that context menu, where am i doing mistake…?
Please guide me, Thanks in Advance….
more_tab_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/feeds"
android:title="Feeds"/>
<item
android:id="@+id/friends"
android:title="Friends"/>
<item
android:id="@+id/about"
android:title="About"/>
</menu>
MenuTest.java
public class MenuTest extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater =getMenuInflater();
inflater.inflate(R.menu.more_tab_menu, menu);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo contextMenuInfo=(AdapterContextMenuInfo)item.getMenuInfo();
switch(item.getItemId())
{
case R.id.feeds:
break;
case R.id.friends:
break;
case R.id.about:
break;
}
return super.onContextItemSelected(item);
}
}
Please tell me where am i doing mistake…?
Right now you have this:
Change it to this:
Also in onOptionsItemSelected:
Also use onCreateOptionsMenu and onOptionsItemSelected.