Please take a look at this official documentation by Google about how to add menu to the Glass app, will give you a direction of how to proceed with designing menu options for glass, without having to follow a lot of steps:
- If you want to add the yes/no options in the Glass activities create menu resources and then display them on a user action, such as a tap when your activity has focus.
- Please note that Glass menus don't support checkable items.
- For each menu item, provide a 50 × 50 pixel menu item icon.
Here is a code snippet for OK option:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/Ok_menu_item"
android:title="@string/Ok" <!-- imperative verb -->
android:icon="@drawable/ic_done_50" />
</menu>
The callbacks in the Menu are handled in the following manner:
- onCreateOptionsMenu() inflates the XML menu resource.
- onPrepareOptionsMenu() shows or hides menu items if required. For example, you can show different menu items based on what users are doing.
- onOptionsItemSelected() handles user selection.
Here is a small code snippet of Java code:
public class MyActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.stopwatch, menu);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.stop:
startActivity(new Intent(this,
StopStopWatchActivity.class));
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
To display the menu, call openOptionsMenu() when required, such as a tap on the touchpad. The following examples detects a tap gesture on an activity and then calls openOptionsMenu().
public class MainActivity extends Activity {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
openOptionsMenu();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
Hope this would help!!