In some situation, you developed an app with optional menu but wants temporary disable it for reason. You may use .setVisible(false).
Before move on to an example, I expect you are familiar with Android Option Menu, if not, please read this this first.
I have prepared an option menu defined below
Then, when the main java, add the following class and set your desired option menu to disable
boolean isLiteVersion = true; @Override public boolean onPrepareOptionsMenu (Menu menu) { if (isLiteVersion) { menu.findItem(R.id.OM_exportSD).setVisible(false); menu.findItem(R.id.OM_importSD).setVisible(false); menu.findItem(R.id.OM_exportDropbox).setVisible(false); menu.findItem(R.id.OM_unlinkDropbox).setVisible(false); } return true; }Some of the option menu will then be be hidden.
Google Android Developer : Menu
Very nice tutorial you on option menu can also check this one at
ReplyDeletehttp://www.pavanh.com/2012/10/android-menu.html