pcm2a pcm2a - 1 year ago 87
Android Question

How to make a dynamic options menu?

The problem is that the following method gets called one time when the Menu button is pressed:

public boolean onCreateOptionsMenu(Menu menu)

How can I recreate the menu at a later time in order to change some options, disable some options, etc?

Answer Source

Override this onPrepareOptionsMenu(Menu menu)

    public boolean onPrepareOptionsMenu(Menu menu) {

        MenuItem item = menu.findItem(R.id.refresh);

        if (item != null) {
         item.setVisible (shouldIShowThisItem)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download