enable Menu Item - Android User Interface

Android examples for User Interface:Menu

Description

enable Menu Item

Demo Code


//package com.java2s;
import android.view.Menu;
import android.view.MenuItem;

public class Main {
    static public MenuItem enableMenuItem(final Menu menu,
            final int itemId, final boolean enabled) {
        final MenuItem mi = menu.findItem(itemId);
        if (mi != null) {
            mi.setVisible(true);/*from   www  . j av  a 2 s  .c om*/
            mi.setEnabled(enabled);
        } // if ...
        return mi;
    }
}

Related Tutorials