Hi I am trying to make Option menu. I am running 2.2 project.
I am making it by documentation but the menu table doesn't show up. Can you help me?
I am making it by documentation but the menu table doesn't show up. Can you help me?
HTML:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_newGame"
android:title="New Game"
/>
<item
android:id="@+id/menu_HighScores"
android:title="Highscores"
/>
<item
android:id="@+id/menu_quit"
android:title="Quit"
/>
</menu>
B4X:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public boolean onCreateOptionMenu(Menu menu)
{
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.layout.menu, menu);
return true;
}
public boolean onOptionItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case R.id.menu_newGame:
// Single menu item is selected do something
// Ex: launching new activity/screen or show alert message
Toast.makeText(GameOfAnagramsActivity.this, "Bookmark is Selected", Toast.LENGTH_SHORT).show();
return true;
case R.id.menu_HighScores:
Toast.makeText(GameOfAnagramsActivity.this, "Save is Selected", Toast.LENGTH_SHORT).show();
return true;
case R.id.menu_quit:
Toast.makeText(GameOfAnagramsActivity.this, "Search is Selected", Toast.LENGTH_SHORT).show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}