Example usage for android.view Menu NONE

List of usage examples for android.view Menu NONE

Introduction

In this page you can find the example usage for android.view Menu NONE.

Prototype

int NONE

To view the source code for android.view Menu NONE.

Click Source Link

Document

Value to use for group and item identifier integers when you don't care about them.

Usage

From source file:org.bohrmeista.chan.ui.activity.ImageViewActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.image_view, menu);

    MenuItem imageSearch = menu.findItem(R.id.action_image_search);
    SubMenu subMenu = imageSearch.getSubMenu();
    for (ImageSearch engine : ImageSearch.engines) {
        subMenu.add(Menu.NONE, engine.getId(), Menu.NONE, engine.getName());
    }//from www.  ja  v  a  2  s . c o  m

    return true;
}

From source file:com.github.pockethub.android.ui.MainActivity.java

private void setUpNavigationMenu() {
    MenuItem organizationContainer = navigationView.getMenu().findItem(R.id.navigation_organizations);
    if (organizationContainer.hasSubMenu()) {
        SubMenu organizationsMenu = organizationContainer.getSubMenu();
        for (int i = 1; i < orgs.size(); i++) {
            User organization = orgs.get(i);
            if (organizationsMenu.findItem(organization.id()) == null) {
                MenuItem organizationMenuItem = organizationsMenu.add(Menu.NONE, organization.id(), Menu.NONE,
                        organization.name() != null ? organization.name() : organization.login());
                organizationMenuItem.setIcon(R.drawable.ic_github_organization_black_24dp);
                //Because of tinting the real image would became a grey block
                //avatars.bind(organizationMenuItem, organization);
                menuItemOrganizationMap.put(organizationMenuItem, organization);
            }/*from w  ww  .jav a  2s .  c  om*/
        }
    } else {
        throw new IllegalStateException("Menu item " + organizationContainer + " should have a submenu");
    }
}

From source file:syncthing.android.ui.LauncherActivity.java

void populateNavigationMenu(Credentials current, boolean goToCurrent) {
    List<Credentials> creds = mSettings.getSavedCredentialsSorted();
    //TODO any way to just clear the devices group?
    mNavigation.getMenu().clear();/*from  w w w  . j av  a 2  s. co m*/
    mNavigation.inflateMenu(R.menu.navigation);
    Menu menu = mNavigation.getMenu();
    for (int ii = 0; ii < creds.size(); ii++) {
        Credentials c = creds.get(ii);
        MenuItem item = menu.add(R.id.nav_devices, Menu.NONE, ii + 1, c.alias);
        item.setIcon(new BitmapDrawable(getResources(), mIdenticonGenerator.generate(c.id)));
        item.setIntent(new Intent().putExtra(ManageActivity.EXTRA_CREDENTIALS, c));
        if (goToCurrent && c.equals(current)) {
            item.setChecked(true);
        }
    }
    if (goToCurrent) {
        if (current != null) {
            openSession(current);
        } else if (creds.isEmpty()) {
            startWelcomeActivity();
        } else {
            Timber.w("No current device");
            openDrawer(GravityCompat.START);
        }
    }
}

From source file:fr.rolandl.smartshareactionprovider.SmartShareActionProvider.java

/**
 * {@inheritDoc}/*from   ww  w .  j  a  v a 2  s . co m*/
 */
@Override
public void onPrepareSubMenu(SubMenu subMenu) {
    // Clear since the order of items may change.
    subMenu.clear();

    SmartActivityChooserModel dataModel = SmartActivityChooserModel.get(mContext, mShareHistoryFileName);
    PackageManager packageManager = mContext.getPackageManager();

    final int expandedActivityCount = dataModel.getActivityCount();
    final int collapsedActivityCount = Math.min(expandedActivityCount, mMaxShownActivityCount);

    // Populate the sub-menu with a sub set of the activities.
    for (int i = 0; i < collapsedActivityCount; i++) {
        ResolveInfo activity = dataModel.getActivity(i);
        subMenu.add(0, i, i, activity.loadLabel(packageManager)).setIcon(activity.loadIcon(packageManager))
                .setOnMenuItemClickListener(mOnMenuItemClickListener);
    }

    if (collapsedActivityCount < expandedActivityCount) {
        // Add a sub-menu for showing all activities as a list item.
        SubMenu expandedSubMenu = subMenu.addSubMenu(Menu.NONE, collapsedActivityCount, collapsedActivityCount,
                mContext.getString(R.string.abc_activity_chooser_view_see_all));
        for (int i = 0; i < expandedActivityCount; i++) {
            ResolveInfo activity = dataModel.getActivity(i);
            expandedSubMenu.add(0, i, i, activity.loadLabel(packageManager))
                    .setIcon(activity.loadIcon(packageManager))
                    .setOnMenuItemClickListener(mOnMenuItemClickListener);
        }
    }
}

From source file:edu.cmu.android.restaurant.MapFragment.java

/**
 * Menu - include 4 items 1. Camera : click to make a photo 2. Coupon :
 * click to find the coupon of the restaurant 3. About : The developer's
 * information/* www  . j  a va2 s  .c o m*/
 * */

public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    super.onCreateOptionsMenu(menu, inflater);
    // 1.group, 2.ID, 3.order, 4.txt
    menu.add(Menu.NONE, Menu.FIRST + 1, 1, "Camera").setIcon(android.R.drawable.ic_menu_camera);
    menu.add(Menu.NONE, Menu.FIRST + 2, 2, "Coupon").setIcon(R.drawable.ic_menu_emoticons);
    menu.add(Menu.NONE, Menu.FIRST + 3, 3, "About").setIcon(android.R.drawable.ic_menu_myplaces);

}

From source file:org.mythdroid.activities.MDActivity.java

/**
 * Add a frontend chooser to the options menu (or action bar on >= 3.0)
 * @param menu menu to add to/*from   w w w  .  ja  v  a2  s.com*/
 */
protected void addFrontendChooser(Menu menu) {

    final MenuItem item = menu.add(Menu.NONE, MENU_FRONTEND, Menu.NONE, R.string.setCurFe)
            .setIcon(drawable.ic_menu_upload_you_tube);

    if (MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS)) {

        ActionView vi = (ActionView) LayoutInflater.from(this).inflate(R.layout.frontend_indicator, null);

        vi.setFocusable(true);

        vi.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                nextActivity = null;
                showDialog(FRONTEND_CHOOSER);
            }
        });

        frontendIndicator = (TextView) vi.findViewById(R.id.actionItemText);
        updateFrontendIndicator();

        MenuItemCompat.setActionView(item, vi);

    }

}

From source file:com.gmail.boiledorange73.ut.map.MapActivityBase.java

/** Called whe the menu is created. */
@Override/*from w  ww .j a v a 2  s  .c  o  m*/
public boolean onCreateOptionsMenu(Menu menu) {
    // zoom (invisible)
    menu.add(Menu.NONE, ID_ZOOM, Menu.NONE, Messages.getString("W_ZOOM"))
            .setIcon(android.R.drawable.ic_menu_zoom).setVisible(false);
    // mylocation (invisible)
    menu.add(Menu.NONE, ID_MYLOCATION, Menu.NONE, Messages.getString("W_MYLOCATION"))
            .setIcon(android.R.drawable.ic_menu_mylocation).setVisible(false);
    // maptypes (invisible)
    menu.add(Menu.NONE, ID_MAPTYPE, Menu.NONE, Messages.getString("W_CHANGE_MAP"))
            .setIcon(android.R.drawable.ic_menu_mapmode).setVisible(false);
    // geocoder (invisible)
    if (this.getGeocoderActivityClass() != null) {
        menu.add(Menu.NONE, ID_GEOCODER, Menu.NONE, Messages.getString("W_GEOCODER"))
                .setIcon(android.R.drawable.ic_menu_search).setVisible(false);
    }
    // more
    SubMenu smMore = menu.addSubMenu(Messages.getString("W_MORE")).setIcon(android.R.drawable.ic_menu_more);
    if (this.getPreferenceActivityClass() != null) {
        smMore.add(Menu.NONE, ID_MORE_PREFERENCES, Menu.NONE, Messages.getString("W_PREFERENCES"));
    }
    // more/externalmap (invisible)
    smMore.add(Menu.NONE, ID_MORE_EXTERNALMAP, Menu.NONE, Messages.getString("W_EXTERNALMAP"))
            .setVisible(false);
    // more/removedownloadedfiles (shown if needed)
    if (this.hasDownloadedFiles()) {
        smMore.add(Menu.NONE, ID_MORE_REMOVEDOWNLOADEDFILES, Menu.NONE,
                Messages.getString("W_REMOVEDOWNLOADEDFILES")).setIcon(android.R.drawable.ic_menu_delete);
    }
    // more/clearcache (2013/08/07)
    smMore.add(Menu.NONE, ID_MORE_CLEARCACHE, Menu.NONE, Messages.getString("W_CLEARCACHE"));

    // more/about
    smMore.add(Menu.NONE, ID_MORE_ABOUT, Menu.NONE, Messages.getString("W_ABOUT"));
    // more/exit
    smMore.add(Menu.NONE, ID_MORE_EXIT, Menu.NONE, Messages.getString("W_EXIT"));
    return super.onCreateOptionsMenu(menu);
}

From source file:br.com.GUI.aulas.Agenda.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.agenda_actions, menu);

    final SearchView searchView = new SearchView(getActivity().getActionBar().getThemedContext());
    searchView.setQueryHint("Search");

    menu.add(Menu.NONE, Menu.NONE, 1, "@string").setIcon(android.R.drawable.ic_menu_search)
            .setActionView(searchView)//from   www.j  av a 2 s  .c  o  m
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    searchView.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            if (newText.length() > 0) {
                // Search
                atualizarAgenda(newText.toString());

            } else {
                // Do something when there's no input
                atualizarAgenda(newText.toString());
            }
            return false;
        }

        @Override
        public boolean onQueryTextSubmit(String arg0) {
            // TODO Auto-generated method stub
            atualizarAgenda(arg0.toString());
            return false;
        }
    });
}

From source file:com.owncloud.android.ui.activity.DrawerActivity.java

/**
 * setup drawer content, basically setting the item selected listener.
 *
 * @param navigationView the drawers navigation view
 *//*from  w w  w.j av  a  2 s  .  c  o  m*/
protected void setupDrawerContent(NavigationView navigationView) {
    // Disable help or feedback on customization
    if (!getResources().getBoolean(R.bool.help_enabled)) {
        navigationView.getMenu().removeItem(R.id.drawer_menu_help);
    }

    if (!getResources().getBoolean(R.bool.feedback_enabled)) {
        navigationView.getMenu().removeItem(R.id.drawer_menu_feedback);
    }

    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            mDrawerLayout.closeDrawers();

            switch (menuItem.getItemId()) {
            case R.id.nav_all_files:
                menuItem.setChecked(true);
                mCheckedMenuItem = menuItem.getItemId();

                allFilesOption();
                // TODO activate when On Device branch is merged
                // MainApp.showOnlyFilesOnDevice(false);
                // refreshDirectory();
                break;
            // TODO activate when On Device branch is merged
            // case R.id.nav_on_device:
            //     menuItem.setChecked(true);
            //     mCheckedMenuItem = menuItem.getItemId();
            //     MainApp.showOnlyFilesOnDevice(true);
            //     refreshDirectory();
            //     break;
            case R.id.nav_uploads:
                Intent uploadListIntent = new Intent(getApplicationContext(), UploadListActivity.class);
                uploadListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(uploadListIntent);
                break;
            case R.id.nav_settings:
                Intent settingsIntent = new Intent(getApplicationContext(), Preferences.class);
                startActivity(settingsIntent);
                break;
            case R.id.drawer_menu_account_add:
                createAccount(false);
                break;
            case R.id.drawer_menu_account_manage:
                Intent manageAccountsIntent = new Intent(getApplicationContext(), ManageAccountsActivity.class);
                startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS);
                break;
            case R.id.drawer_menu_feedback:
                openFeedback();
                break;
            case R.id.drawer_menu_help:
                openHelp();
                break;
            case Menu.NONE:
                // account clicked
                accountClicked(menuItem.getTitle().toString());
            default:
                Log_OC.i(TAG, "Unknown drawer menu item clicked: " + menuItem.getTitle());
            }

            return true;
        }
    });

    // handle correct state
    if (mIsAccountChooserActive) {
        navigationView.getMenu().setGroupVisible(R.id.drawer_menu_accounts, true);

    } else {
        navigationView.getMenu().setGroupVisible(R.id.drawer_menu_accounts, false);
    }
}

From source file:com.ustadmobile.port.android.view.CatalogOPDSFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (mDeleteOptionAvailable && mSelectedEntries.length > 0) {
        MenuItem item = menu.add(Menu.NONE, MENUCMDID_DELETE, 1, "");
        item.setIcon(R.drawable.ic_delete_white_24dp);
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    }//from w w w. jav a  2s  .c o m

    super.onCreateOptionsMenu(menu, inflater);

}