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:com.example.javier.MaterialDesignApp.PlayerActivity.java

private void configurePopupWithTracks(PopupMenu popup, final OnMenuItemClickListener customActionClickListener,
        final int trackType) {
    if (player == null) {
        return;/*  w  ww .j a va 2  s .  c  o m*/
    }
    String[] tracks = player.getTracks(trackType);
    if (tracks == null) {
        return;
    }
    popup.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            return (customActionClickListener != null && customActionClickListener.onMenuItemClick(item))
                    || onTrackItemClick(item, trackType);
        }
    });
    Menu menu = popup.getMenu();
    // ID_OFFSET ensures we avoid clashing with Menu.NONE (which equals 0)
    menu.add(MENU_GROUP_TRACKS, DemoPlayer.DISABLED_TRACK + ID_OFFSET, Menu.NONE, R.string.off);
    if (tracks.length == 1 && TextUtils.isEmpty(tracks[0])) {
        menu.add(MENU_GROUP_TRACKS, DemoPlayer.PRIMARY_TRACK + ID_OFFSET, Menu.NONE, R.string.on);
    } else {
        for (int i = 0; i < tracks.length; i++) {
            menu.add(MENU_GROUP_TRACKS, i + ID_OFFSET, Menu.NONE, tracks[i]);
        }
    }
    menu.setGroupCheckable(MENU_GROUP_TRACKS, true, true);
    menu.findItem(player.getSelectedTrackIndex(trackType) + ID_OFFSET).setChecked(true);
}

From source file:apps.junkuvo.alertapptowalksafely.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // ??/*from  ww w .ja  v a 2  s  . co  m*/
    MenuItem actionItem = menu.add(Menu.NONE, MENU_ID.SETTING.ordinal(), MENU_ID.SETTING.ordinal(),
            this.getString(R.string.menu_title_setting));
    actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    actionItem.setIcon(MENU_ID.SETTING.getDrawableResId());

    // Twitter?
    actionItem = menu.add(Menu.NONE, MENU_ID.TWITTER.ordinal(), MENU_ID.TWITTER.ordinal(),
            this.getString(R.string.menu_title_share));
    actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    actionItem.setIcon(MENU_ID.TWITTER.getDrawableResId());

    // Facebook
    actionItem = menu.add(Menu.NONE, MENU_ID.FACEBOOK.ordinal(), MENU_ID.FACEBOOK.ordinal(),
            this.getString(R.string.menu_title_facebook));
    actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    actionItem.setIcon(MENU_ID.FACEBOOK.getDrawableResId());

    if (enableNewFunction) {
        // HISTORY
        actionItem = menu.add(Menu.NONE, MENU_ID.HISTORY.ordinal(), MENU_ID.HISTORY.ordinal(),
                this.getString(R.string.menu_title_history));
        actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        actionItem.setIcon(MENU_ID.HISTORY.getDrawableResId());

    }

    // LINE
    actionItem = menu.add(Menu.NONE, MENU_ID.LINE.ordinal(), MENU_ID.LINE.ordinal(),
            this.getString(R.string.menu_title_line));
    actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    actionItem.setIcon(MENU_ID.LINE.getDrawableResId());

    // FEEDBACK
    actionItem = menu.add(Menu.NONE, MENU_ID.FEEDBACK.ordinal(), MENU_ID.FEEDBACK.ordinal(),
            this.getString(R.string.menu_title_feedback));
    actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    actionItem.setIcon(MENU_ID.FEEDBACK.getDrawableResId());

    // LICENSE
    actionItem = menu.add(Menu.NONE, MENU_ID.LICENSE.ordinal(), MENU_ID.LICENSE.ordinal(),
            this.getString(R.string.menu_title_license));
    actionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    actionItem.setIcon(MENU_ID.LICENSE.getDrawableResId());

    return true;
}

From source file:org.alfresco.mobile.android.application.fragments.sync.SyncFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    info = SyncScanInfo.getLastSyncScanData(getActivity(), acc);
    if (info != null && (info.hasWarning() && !info.hasResponse())) {
        mi = menu.add(Menu.NONE, R.id.menu_sync_warning, Menu.FIRST, R.string.sync_warning);
        mi.setIcon(R.drawable.ic_warning);
        mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }/*  w ww.  j  a va2 s.c o m*/

    MenuFragmentHelper.getMenu(getActivity(), menu);
}

From source file:de.vanita5.twittnuker.util.Utils.java

public static void addIntentToMenu(final Context context, final Menu menu, final Intent queryIntent) {
    addIntentToMenu(context, menu, queryIntent, Menu.NONE);
}

From source file:com.fvd.nimbus.BrowseActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    //if (wv.getInjected()) return;
    menu.add(Menu.NONE, IDM_OPEN, Menu.NONE, "Save Page");
    menu.add(Menu.NONE, IDM_SAVE, Menu.NONE, "Save Image");
    menu.add(Menu.NONE, IDM_SAVE, Menu.NONE, "Take Screenshot");
}

From source file:net.henryco.opalette.application.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    topBarButton = menu.add(0, topBarButtonId, 0, "");
    topBarButton.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    topOptButton = menu.add(Menu.NONE, topOptButtonId, Menu.NONE, "");
    topOptButton.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    restoreTopBarButton();/* www  . j a  va  2 s .  c o m*/
    return super.onCreateOptionsMenu(menu);
}

From source file:de.vanita5.twittnuker.util.Utils.java

public static void addIntentToMenu(final Context context, final Menu menu, final Intent queryIntent,
        final int groupId) {
    if (context == null || menu == null || queryIntent == null)
        return;// w  w w  .  ja v  a 2s.c  o  m
    final PackageManager pm = context.getPackageManager();
    final Resources res = context.getResources();
    final float density = res.getDisplayMetrics().density;
    final int padding = Math.round(density * 4);
    final List<ResolveInfo> activities = pm.queryIntentActivities(queryIntent, 0);
    for (final ResolveInfo info : activities) {
        final Intent intent = new Intent(queryIntent);
        final Drawable icon = info.loadIcon(pm);
        intent.setClassName(info.activityInfo.packageName, info.activityInfo.name);
        final MenuItem item = menu.add(groupId, Menu.NONE, Menu.NONE, info.loadLabel(pm));
        item.setIntent(intent);
        final int iw = icon.getIntrinsicWidth(), ih = icon.getIntrinsicHeight();
        if (iw > 0 && ih > 0) {
            final Drawable iconWithPadding = new PaddingDrawable(icon, padding);
            iconWithPadding.setBounds(0, 0, iw, ih);
            item.setIcon(iconWithPadding);
        } else {
            item.setIcon(icon);
        }
    }
}

From source file:in.andres.kandroid.ui.MainActivity.java

private void populateProjectsMenu() {
    if (mProjectList == null) {
        if (BuildConfig.DEBUG)
            Log.d("Kandroid", "Tried to populate drawer, but mDashboard was null");
        return;// w  w  w  .  j a va 2s  .com
    }
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getBaseContext());
    List<KanboardProject> projList = mProjectList;
    if (preferences.getBoolean("projects_sort_alphabetic", false))
        Collections.sort(projList);
    NavigationView nav = (NavigationView) findViewById(R.id.nav_view);
    SubMenu projMenu = nav.getMenu().findItem(R.id.projects).getSubMenu();
    projMenu.clear();
    for (KanboardProject item : projList)
        projMenu.add(Menu.NONE, item.getId(), Menu.NONE, item.getName()).setIcon(R.drawable.project);
}

From source file:tw.com.geminihsu.app01.fragment.Fragment_Client_Service_test.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    MenuItem item = menu.add(Menu.NONE, ACTIONBAR_MENU_ITEM_FIILTER, Menu.NONE,
            getString(R.string.order_call_taxi_page_title));
    SpannableString spanString = new SpannableString(item.getTitle().toString());
    spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0); //fix the color to white
    item.setTitle(spanString);/*from  ww w  . j  av a 2 s .  c  o  m*/
    Utility driver = new Utility(getActivity());

    if (isShowOneKey && driver.getAllDriverAccountInfo().isEmpty())
        item.setVisible(true);
    else
        item.setVisible(false);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    super.onCreateOptionsMenu(menu, inflater);
}

From source file:org.catnut.fragment.ProfileFragment.java

private void buildMenu() {
    if (mMenu != null && mAvatarUrl != null) { // ???sqlite
        // ???menu
        if (mMenu.findItem(R.id.action_follow) == null && mMenu.findItem(R.id.action_unfollow) == null) {
            if (!mFollowing) {
                mMenu.add(Menu.NONE, R.id.action_follow, Menu.NONE, R.string.follow)
                        .setIcon(R.drawable.ic_title_follow).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
            } else {
                mMenu.add(Menu.NONE, R.id.action_unfollow, Menu.NONE, R.string.unfollow)
                        .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
            }/*from  w w w. j  a  va  2 s.c o  m*/
        }
    }
}