Search code examples
google-glassgoogle-gdk

How do you use setInitialMenuItem for Google Glass menus, and do you have example code?


Google Glass online documentation mentions the method but with minimal documentation:

https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/view/MenuUtils

Should this be called from onOptionsItemSelected or onCreateOptionsMenu?

Any example code would be most appreciated.


Solution

  • You should call this method from onCreateOptionsMenu or onPrepareOptionsMenu in order to set the menu item that will be initially visible when the user asks for the menu to be displayed. If you call it from onOptionsItemSelected, then it will be too late, since the menu was already displayed and interacted with.