android.view.Menu Java Examples

The following examples show how to use android.view.Menu. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TvShowEpisodesFragment.java    From Mizuu with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.episodes_overview, menu);

    int padding = MizLib.convertDpToPixels(getActivity(), 16);

    SwitchCompat switchCompat = (SwitchCompat) menu.findItem(R.id.switch_button).getActionView();
    switchCompat.setChecked(mEpisodeLoader != null ? mEpisodeLoader.showAvailableFiles() : false);
    switchCompat.setText(R.string.choiceAvailableFiles);
    switchCompat.setSwitchPadding(padding);
    switchCompat.setPadding(0, 0, padding, 0);

    switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mEpisodeLoader.setShowAvailableFiles(isChecked);
            mEpisodeLoader.load();
            showProgressBar();
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}
 
Example #2
Source File: AppMenu.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Creates and sets up the App Menu.
 * @param menu Original menu created by the framework.
 * @param itemRowHeight Desired height for each app menu row.
 * @param itemDividerHeight Desired height for the divider between app menu items.
 * @param handler AppMenuHandler receives callbacks from AppMenu.
 * @param res Resources object used to get dimensions and style attributes.
 */
AppMenu(Menu menu, int itemRowHeight, int itemDividerHeight, AppMenuHandler handler,
        Resources res) {
    mMenu = menu;

    mItemRowHeight = itemRowHeight;
    assert mItemRowHeight > 0;

    mHandler = handler;

    mItemDividerHeight = itemDividerHeight;
    assert mItemDividerHeight >= 0;

    mNegativeSoftwareVerticalOffset =
            res.getDimensionPixelSize(R.dimen.menu_negative_software_vertical_offset);
    mVerticalFadeDistance = res.getDimensionPixelSize(R.dimen.menu_vertical_fade_distance);
}
 
Example #3
Source File: SMSConversationFragment.java    From BlackList with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.main, menu);

    MenuItem menuItem = menu.findItem(R.id.write_message);
    Utils.setMenuIconTint(getContext(), menuItem, R.attr.colorAccent);
    menuItem.setVisible(true);
    menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            // open activity with fragment of sending SMS
            openSMSSendActivity(contactName, contactNumber, messageEdit.getText().toString());
            messageEdit.setText("");
            return true;
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}
 
Example #4
Source File: PreferencesFragment.java    From Android-PreferencesManager with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("ConstantConditions")
@Override
public void onPrepareOptionsMenu(Menu menu) {
    menu.findItem(R.id.action_add).setEnabled(preferenceFile != null && preferenceFile.isValidPreferenceFile());
    menu.findItem(R.id.action_add).setIcon(preferenceFile != null && preferenceFile.isValidPreferenceFile() ? R.drawable.ic_action_add : R.drawable.ic_action_add_disabled);
    MenuItem sortAlpha = menu.findItem(R.id.action_sort_alpha);
    MenuItem sortType = menu.findItem(R.id.action_sort_type);
    sortAlpha.setChecked(false);
    sortType.setChecked(false);
    if (PreferencesActivity.preferenceSortType == PreferenceSortType.ALPHANUMERIC) {
        sortAlpha.setChecked(true);
    } else if (PreferencesActivity.preferenceSortType == PreferenceSortType.TYPE_AND_ALPHANUMERIC) {
        sortType.setChecked(true);
    }
    menu.findItem(R.id.action_restore_file).setVisible(mListener != null && mListener.canRestoreFile(mFile));
    super.onPrepareOptionsMenu(menu);
}
 
Example #5
Source File: ExperimentListFragment.java    From science-journal with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  super.onCreateOptionsMenu(menu, inflater);
  if (claimExperimentsMode) {
    inflater.inflate(R.menu.menu_claim_experiments, menu);
    ColorUtils.colorDrawable(
        applicationContext,
        menu.findItem(R.id.run_review_overflow_menu).getIcon(),
        R.color.claim_experiments_action_bar_text);

  } else {
    inflater.inflate(R.menu.menu_experiment_list, menu);
  }
  optionsMenu = menu;
  updateNetworkStatusIcon();
}
 
Example #6
Source File: Scoop.java    From Scoops with Apache License 2.0 6 votes vote down vote up
/**
 * Apply the attributed menu item tint to all the icons if the attribute {@link R.attr#toolbarItemTint}
 *
 * @param context      the application context to derive the attr color from
 * @param menu          the menu to apply to
 */
public void apply(Context context, Menu menu){
    Flavor flavor = getCurrentFlavor();
    if(menu != null && menu.size() > 0 && flavor != null){
        int tint = AttrUtils.getColorAttr(context, flavor.getStyleResource(), R.attr.toolbarItemTint);
        for (int i = 0; i < menu.size(); i++) {
            MenuItem item = menu.getItem(i);
            Drawable icon = item.getIcon();
            if(icon != null){
                if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
                    icon.setTint(tint);
                }else{
                    icon.setColorFilter(tint, PorterDuff.Mode.SRC_ATOP);
                }
            }
        }
    }
}
 
Example #7
Source File: MainActivity.java    From android_gisapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    if (null != mLayersFragment && !mLayersFragment.isDrawerOpen()) {
        // Only show items in the action bar relevant to this screen
        // if the drawer is not showing. Otherwise, let the drawer
        // decide what to show in the action bar.
        getMenuInflater().inflate(R.menu.main, menu);
        //restoreActionBar();

        return true;
    }
    return super.onCreateOptionsMenu(menu);
}
 
Example #8
Source File: MainActivity.java    From Android-HomeKey-Locker with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
 
Example #9
Source File: FolioActivity.java    From ankihelper with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);

    Config config = AppUtil.getSavedConfig(getApplicationContext());
    assert config != null;
    UiUtil.setColorIntToDrawable(config.getThemeColor(), menu.findItem(R.id.itemSearch).getIcon());
    UiUtil.setColorIntToDrawable(config.getThemeColor(), menu.findItem(R.id.itemConfig).getIcon());
    UiUtil.setColorIntToDrawable(config.getThemeColor(), menu.findItem(R.id.itemTts).getIcon());

    if (!config.isShowTts())
        menu.findItem(R.id.itemTts).setVisible(false);

    return true;
}
 
Example #10
Source File: PrivacyPreferences.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    MenuItem help = menu.add(
            Menu.NONE, R.id.menu_id_targeted_help, Menu.NONE, R.string.menu_help);
    help.setIcon(R.drawable.ic_help_and_feedback);
}
 
Example #11
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	MenuInflater menuInflater = getMenuInflater();
	menuInflater.inflate(R.menu.menu_main, menu);
	this.menu = menu;
	return true;
}
 
Example #12
Source File: ShoppingCurrentCityActivity.java    From Travel-Mate with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.search_menu, menu);
    MenuItem item = menu.findItem(R.id.action_search);
    mSearchView.setMenuItem(item);
    return true;
}
 
Example #13
Source File: WebMediumActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
       boolean isAdmin = (MainActivity.user != null) && this.instance.isAdmin;
       if (!isAdmin || this.instance.isExternal) {
       	menu.findItem(R.id.menuAdmin).setEnabled(false);
       }
       if (isAdmin || this.instance.isFlagged) {
       	menu.findItem(R.id.menuFlag).setEnabled(false);
       }
    return true;
}
 
Example #14
Source File: InviteFragment.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    this.menu = menu;
    this.inflater = inflater;
    showMenu();
}
 
Example #15
Source File: OpenTypeShapingActivity.java    From Tehreer-Android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_opentype_shaping, menu);

    return true;
}
 
Example #16
Source File: CommonBaseActivity.java    From Primary with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main_menu, menu);

    return true;
}
 
Example #17
Source File: CordovaActivity.java    From cordova-plugin-app-update-demo with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (appView != null) {
        appView.getPluginManager().postMessage("onCreateOptionsMenu", menu);
    }
    return super.onCreateOptionsMenu(menu);
}
 
Example #18
Source File: OCFileListFragment.java    From Cirrus_depricated with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    searchItem = menu.findItem(R.id.action_search);
    layoutView = menu.findItem(R.id.action_changeView);

    // create search bar and search listener
    if (searchItem != null) {
        searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
        searchView.setOnQueryTextListener(this);
    }
}
 
Example #19
Source File: EarlySmokeWarningFragment.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onPrepareOptionsMenu(Menu menu) {
    MenuItem item = menu.findItem(R.id.menu_edit_done);
    if(item != null) {
        item.setTitle(getResources().getString(R.string.card_menu_done));
    }

    super.onPrepareOptionsMenu(menu);
}
 
Example #20
Source File: MainActivity.java    From user-interface-samples with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem logToggle = menu.findItem(R.id.menu_toggle_log);
    logToggle.setVisible(findViewById(R.id.sample_output) instanceof ViewAnimator);
    logToggle.setTitle(mLogShown ? R.string.sample_hide_log : R.string.sample_show_log);

    return super.onPrepareOptionsMenu(menu);
}
 
Example #21
Source File: AbstractActionActivity.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public final boolean onPrepareOptionsMenu(final Menu menu) {
    super.onPrepareOptionsMenu(menu);
    if (menu != null) {
        updateMenuItems(menu);
    }
    return true;
}
 
Example #22
Source File: CommentActivity.java    From ting with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.song_menu, menu);

    MenuItem item = menu.findItem(R.id.action_share);
    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    return true;
}
 
Example #23
Source File: ChooseContactActivity.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    super.onCreateOptionsMenu(menu);
    final Intent i = getIntent();
    boolean showEnterJid = i != null && i.getBooleanExtra(EXTRA_SHOW_ENTER_JID, false);
    menu.findItem(R.id.action_scan_qr_code).setVisible(isCameraFeatureAvailable() && showEnterJid);
    MenuItem mMenuSearchView = menu.findItem(R.id.action_search);
    if (startSearching) {
        mMenuSearchView.expandActionView();
    }
    return true;
}
 
Example #24
Source File: MainActivity.java    From animation-samples with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem logToggle = menu.findItem(R.id.menu_toggle_log);
    logToggle.setVisible(findViewById(R.id.sample_output) instanceof ViewAnimator);
    logToggle.setTitle(mLogShown ? R.string.sample_hide_log : R.string.sample_show_log);

    return super.onPrepareOptionsMenu(menu);
}
 
Example #25
Source File: MainActivity.java    From MOAAP with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    Log.i(TAG, "called onCreateOptionsMenu");
    mItemSwitchCamera = menu.add("切换前置/后置摄像头");
    return true;
}
 
Example #26
Source File: MainActivity.java    From restcomm-android-sdk with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
   // Inflate the menu; this adds items to the action bar if it is present.
   getMenuInflater().inflate(R.menu.menu_main, menu);
   return true;
}
 
Example #27
Source File: MainActivity.java    From friendspell with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.activity_main, menu);

  this.menu = menu;
  updateMenuItems();

  return true;
}
 
Example #28
Source File: InstagramGalleryActivity.java    From InstagramPhotoPicker-Android with MIT License 5 votes vote down vote up
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.photo_selection_menu, menu);

    int selectCount = gridView.getCheckedItemCount();
    mode.setTitle("" + selectCount);

    return true;
}
 
Example #29
Source File: PublishesFragment.java    From lbry-android with MIT License 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
    this.actionMode = actionMode;
    Context context = getContext();
    if (context instanceof MainActivity) {
        MainActivity activity = (MainActivity) context;
        if (!activity.isDarkMode()) {
            activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
        }
    }

    actionMode.getMenuInflater().inflate(R.menu.menu_claim_list, menu);
    return true;
}
 
Example #30
Source File: FragmentActivity.java    From android-recipes-app with Apache License 2.0 5 votes vote down vote up
/**
 * Dispatch onPrepareOptionsMenu() to fragments.
 */
@Override
public boolean onPreparePanel(int featureId, View view, Menu menu) {
    if (featureId == Window.FEATURE_OPTIONS_PANEL && menu != null) {
        if (mOptionsMenuInvalidated) {
            mOptionsMenuInvalidated = false;
            menu.clear();
            onCreatePanelMenu(featureId, menu);
        }
        boolean goforit = onPrepareOptionsPanel(view, menu);
        goforit |= mFragments.dispatchPrepareOptionsMenu(menu);
        return goforit;
    }
    return super.onPreparePanel(featureId, view, menu);
}