android.view.Menu源码实例Demo

类android.view.Menu源码实例Demo

下面列出了android.view.Menu 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Mizuu   文件: TvShowEpisodesFragment.java
@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);
}
 
源代码2 项目: Scoops   文件: Scoop.java
/**
 * 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);
                }
            }
        }
    }
}
 
源代码3 项目: science-journal   文件: ExperimentListFragment.java
@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();
}
 
源代码4 项目: AndroidChromium   文件: AppMenu.java
/**
 * 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);
}
 
源代码5 项目: BlackList   文件: SMSConversationFragment.java
@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);
}
 
@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);
}
 
源代码7 项目: foodie-app   文件: DishInfoActivity.java
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem menuItem = menu.findItem(R.id.action_favorite);
    Log.i(TAG, "Pre" + isDishFavorite);
    menuItem.setIcon(isDishFavorite?iconFavorite[1]:iconFavorite[0]);
    return super.onPrepareOptionsMenu(menu);
}
 
源代码8 项目: Android-HomeKey-Locker   文件: MainActivity.java
@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;
}
 
源代码9 项目: ForPDA   文件: DeviceFragment.java
@Override
protected void addBaseToolbarMenu(Menu menu) {
    super.addBaseToolbarMenu(menu);
    copyLinkMenuItem = menu.add(R.string.copy_link)
            .setOnMenuItemClickListener(item -> {
                Utils.copyToClipBoard("https://4pda.ru/devdb/" + currentData.getId());
                return true;
            });

    shareMenuItem = menu.add(R.string.share)
            .setOnMenuItemClickListener(item -> {
                Utils.shareText("https://4pda.ru/devdb/" + currentData.getId());
                return true;
            });

    noteMenuItem = menu.add(R.string.create_note)
            .setOnMenuItemClickListener(item -> {
                String title = "DevDb: " + currentData.getBrandTitle() + " " + currentData.getTitle();
                String url = "https://4pda.ru/devdb/" + currentData.getId();
                NotesAddPopup.showAddNoteDialog(getContext(), title, url);
                return true;
            });

    toBrandMenuItem = menu.add(R.string.devices)
            .setOnMenuItemClickListener(item -> {
                IntentHandler.handle("https://4pda.ru/devdb/" + currentData.getCatId() + "/" + currentData.getBrandId());
                return true;
            });

    toBrandsMenuItem = menu.add(R.string.devices)
            .setOnMenuItemClickListener(item -> {
                IntentHandler.handle("https://4pda.ru/devdb/" + currentData.getCatId());
                return true;
            });

    refreshToolbarMenuItems(false);
}
 
源代码10 项目: Shield   文件: LightAgentManager.java
public void onOptionsMenuClosed(Menu menu) {
    for (String name : agentList) {
        AgentInterface agent = agents.get(name);
        if (agent != null && agent instanceof FullOptionMenuLifecycle) {
            ((FullOptionMenuLifecycle) agent).onOptionsMenuClosed(menu);
        }
    }
}
 
源代码11 项目: Android_Blog_Demos   文件: ColourImageActivity.java
@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_colour_image, menu);
    return true;
}
 
@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
    final MenuItem actionItemAdd = menu.add(0, OPTIONS_MENU_ADD, 0,
            R.string.user_dict_settings_add_menu_title).setIcon(R.drawable.ic_menu_add);
    actionItemAdd.setShowAsAction(
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    final MenuItem actionItemDelete = menu.add(0, OPTIONS_MENU_DELETE, 0,
            R.string.user_dict_settings_delete).setIcon(android.R.drawable.ic_menu_delete);
    actionItemDelete.setShowAsAction(
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
 
源代码13 项目: delion   文件: PrivacyPreferences.java
@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);
}
 
源代码14 项目: bitseal   文件: IdentitiesActivity.java
@Override
  public boolean onPrepareOptionsMenu(Menu menu)
  {
  	SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
  	if (prefs.getBoolean(KEY_DATABASE_PASSPHRASE_SAVED, false) == false)
{
	menu.removeItem(R.id.menu_item_lock);
}
      return super.onPrepareOptionsMenu(menu);
  }
 
源代码15 项目: Ency   文件: WebActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (isShowLikeIcon) {
        getMenuInflater().inflate(R.menu.menu_web1, menu);
        menuItem = menu.findItem(R.id.item_like);
        setLikeState(daoManager.queryByGuid(guid));
    } else {
        getMenuInflater().inflate(R.menu.menu_web2, menu);
    }
    return true;
}
 
源代码16 项目: telegram-sms   文件: main_activity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main_menu, menu);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
        MenuItem set_proxy_item = menu.findItem(R.id.set_proxy);
        set_proxy_item.setVisible(false);
    }
    return true;
}
 
源代码17 项目: ankihelper   文件: FolioActivity.java
@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;
}
 
源代码18 项目: BotLibre   文件: MainActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	MenuInflater menuInflater = getMenuInflater();
	menuInflater.inflate(R.menu.menu_main, menu);
	this.menu = menu;
	return true;
}
 
源代码19 项目: Travel-Mate   文件: ShoppingCurrentCityActivity.java
@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;
}
 
源代码20 项目: BotLibre   文件: WebMediumActivity.java
@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;
}
 
源代码21 项目: AndroidChromium   文件: PrivacyPreferences.java
@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);
}
 
源代码22 项目: Tehreer-Android   文件: OpenTypeShapingActivity.java
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_opentype_shaping, menu);

    return true;
}
 
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (appView != null) {
        appView.getPluginManager().postMessage("onCreateOptionsMenu", menu);
    }
    return super.onCreateOptionsMenu(menu);
}
 
源代码24 项目: Cirrus_depricated   文件: OCFileListFragment.java
@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);
    }
}
 
源代码25 项目: android_gisapp   文件: MainActivity.java
@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);
}
 
源代码26 项目: user-interface-samples   文件: MainActivity.java
@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);
}
 
源代码27 项目: document-viewer   文件: AbstractActionActivity.java
@Override
public final boolean onPrepareOptionsMenu(final Menu menu) {
    super.onPrepareOptionsMenu(menu);
    if (menu != null) {
        updateMenuItems(menu);
    }
    return true;
}
 
源代码28 项目: Pix-Art-Messenger   文件: ChooseContactActivity.java
@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;
}
 
源代码29 项目: animation-samples   文件: MainActivity.java
@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);
}
 
源代码30 项目: MOAAP   文件: MainActivity.java
@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;
}
 
如果文章对您有帮助,请点击页面广告。以鼓励作者做出的努力。
 类所在包
 同包方法