Code example for Menu

Methods: add

0
 
    // Demonstrate how to add your own menus to app 
 
    @Override 
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        int base = Menu.FIRST;
        // Group, item id, order, title 
        menu.add(base, base, base, "Item1");
        menu.add(base, base + 1, base + 1, "Item2");
        menu.add(base, base + 2, base + 2, "Item3");
        return true; 
    } 
 
    @Override 
    public boolean onOptionsItemSelected(MenuItem item) {
        LOG.d("menus", "Item " + item.getItemId() + " pressed.");
        this.appView.loadUrl("javascript:alert('Menu " + item.getItemId() + " pressed.')");
        return super.onOptionsItemSelected(item);
    } 
Experience pair programming with AI  Get Codota for Java