当前位置: 首页>>代码示例>>Java>>正文


Java Menu.findItem方法代码示例

本文整理汇总了Java中android.view.Menu.findItem方法的典型用法代码示例。如果您正苦于以下问题:Java Menu.findItem方法的具体用法?Java Menu.findItem怎么用?Java Menu.findItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.Menu的用法示例。


在下文中一共展示了Menu.findItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_menu, menu);

    MenuItem about = menu.findItem(R.id.menu_about);
    switch (remoteConfig.getExperimentVariant(IRemoteConfig.EXPERIMENT_ABOUT_MENU)) {
        case VARIANT_A:
            about.setIcon(R.drawable.ic_info_sign);
            about.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
            break;
        case VARIANT_B:
            about.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
            break;
        default:
            about.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    return true;
}
 
开发者ID:riteshakya037,项目名称:Wallpapers-Android-Clean-Architecture,代码行数:20,代码来源:OnBoardingActivity.java

示例2: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu (Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    MenuItem item = menu.findItem(R.id.action_enable);
    item.setActionView(R.layout.switch_layout);
    SwitchCompat mSwitchEnablePush = item.getActionView().findViewById(R.id.switchForActionBar);
    mSwitchEnablePush.setChecked(PushController.isAllEnable(this));
    mSwitchEnablePush.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            PushController.setAllEnable(b, MainActivity.this);
            Toast.makeText(MainActivity.this,
                    b ? R.string.msg_enable : R.string.msg_disable
                    , Toast.LENGTH_SHORT).show();
        }
    });
    return true;
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:19,代码来源:MainActivity.java

示例3: onPrepareOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    MenuItem menuItem = menu.findItem(R.id.action_wrap_lines);
    MenuItem menuItemDownload = menu.findItem(R.id.action_download);
    MenuItem menuItemViewFile = menu.findItem(R.id.action_view_file);
    MenuItem menuItemRefresh = menu.findItem(R.id.action_refresh);
    if(ViewerActivity.ViewerType.RepoFile.equals(mPresenter.getViewerType())) {
        menuItem.setVisible(mPresenter.isCode() && !StringUtils.isBlank(mPresenter.getDownloadSource()));
        menuItem.setChecked(wrap);
        menuItemDownload.setVisible(!StringUtils.isBlank(mPresenter.getFileModel().getDownloadUrl()));
        menuItemViewFile.setVisible(false);
        menuItemRefresh.setVisible(true);
    } else if(ViewerActivity.ViewerType.DiffFile.equals(mPresenter.getViewerType())){
        menuItem.setVisible(true);
        menuItem.setChecked(wrap);
        menuItemDownload.setVisible(false);
        menuItemViewFile.setVisible(true);
        menuItemRefresh.setVisible(false);
    } else if(ViewerActivity.ViewerType.Image.equals(mPresenter.getViewerType())) {
        menuItem.setVisible(false);
        menuItemViewFile.setVisible(false);
        menuItemRefresh.setVisible(false);
    }
}
 
开发者ID:ThirtyDegreesRay,项目名称:OpenHub,代码行数:26,代码来源:ViewerFragment.java

示例4: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if(mPresenter.getRepository() != null){
        getMenuInflater().inflate(R.menu.menu_repository, menu);
        MenuItem starItem = menu.findItem(R.id.action_star);
        MenuItem bookmark = menu.findItem(R.id.action_bookmark);
        starItem.setTitle(mPresenter.isStarred() ? R.string.unstar : R.string.star);
        starItem.setIcon(mPresenter.isStarred() ?
                R.drawable.ic_star_title : R.drawable.ic_un_star_title);
        menu.findItem(R.id.action_watch).setTitle(mPresenter.isWatched() ?
                R.string.unwatch : R.string.watch);
        menu.findItem(R.id.action_fork).setTitle(mPresenter.isFork() ?
                R.string.forked : R.string.fork);
        menu.findItem(R.id.action_fork).setVisible(mPresenter.isForkEnable());
        bookmark.setTitle(mPresenter.isBookmarked() ?
                getString(R.string.remove_bookmark) : getString(R.string.bookmark));
        menu.findItem(R.id.action_wiki).setVisible(mPresenter.getRepository().isHasWiki());
    }
    return true;
}
 
开发者ID:ThirtyDegreesRay,项目名称:OpenHub,代码行数:21,代码来源:RepositoryActivity.java

示例5: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (showReloadPlacesButton) {
        getMenuInflater().inflate(R.menu.main_menu, menu);
        final MenuItem myActionMenuItem = menu.findItem(R.id.action_refresh);
        myActionMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                PlaceFragment placeFragment = (PlaceFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_container);
                if (placeFragment.isAdded()) {
                    placeFragment.currentPlace();
                }
                return false;
            }
        });
    }
    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:OpenLocate,项目名称:openlocate-android,代码行数:19,代码来源:MainActivity.java

示例6: onPrepareOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    if (app == null) {
        return true;
    }
    MenuItem itemIgnoreAll = menu.findItem(R.id.action_ignore_all);
    if (itemIgnoreAll != null) {
        itemIgnoreAll.setChecked(app.getPrefs(this).ignoreAllUpdates);
    }
    MenuItem itemIgnoreThis = menu.findItem(R.id.action_ignore_this);
    if (itemIgnoreThis != null) {
        itemIgnoreThis.setVisible(app.hasUpdates());
        itemIgnoreThis.setChecked(app.getPrefs(this).ignoreThisUpdate >= app.suggestedVersionCode);
    }
    return true;
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:18,代码来源:AppDetails2.java

示例7: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_edit, menu);

    if (mPreviewMode) {
        MenuItem item = menu.findItem(R.id.action_preview);
        item.setIcon(R.drawable.ic_edit);
        item.setTitle(R.string.action_edit);
    }
    return true;
}
 
开发者ID:nfdz,项目名称:foco,代码行数:12,代码来源:EditDocActivity.java

示例8: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {

    getMenuInflater().inflate(R.menu.menu_main, menu);
    MenuItem item = menu.findItem(R.id.menu_store);
    if (developerUrl != null) {
        item.setVisible(true);
    }

    return true;
}
 
开发者ID:searchy2,项目名称:AndroidCrossPromotion,代码行数:12,代码来源:AdActivity.java

示例9: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MenuItem searchMenuItem = menu.findItem(R.id.action_search);
    MenuItem importItem = menu.findItem(R.id.action_import);
    importItem.setVisible(true);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setQueryHint(getString(R.string.search));
    searchView.onActionViewExpanded();
    searchView.clearFocus();
    searchView.setSubmitButtonEnabled(false);
    searchView.setQueryRefinementEnabled(false);
    searchView.setOnQueryTextListener(this);
}
 
开发者ID:jboss-outreach,项目名称:lead-management-android,代码行数:15,代码来源:ContactsFragment.java

示例10: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_empresas, menu);

    final MenuItem searchItem = menu.findItem(R.id.item_buscar_empresas);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setOnQueryTextListener(this);
}
 
开发者ID:ur13l,项目名称:Guanajoven,代码行数:10,代码来源:EmpresaFragment.java

示例11: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.cast_browse, menu);
    mediaRouteMenuItem = CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), menu,
            R.id.media_route_menu_item);
    mQueueMenuItem = menu.findItem(R.id.action_show_queue);
    showIntroductoryOverlay();
    return true;
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:11,代码来源:VideoBrowserActivity.java

示例12: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.fragment_locatr, menu);

    MenuItem searchItem = menu.findItem(R.id.action_locate);
    searchItem.setEnabled(mClient.isConnected());
}
 
开发者ID:ivicel,项目名称:Android-Programming-BigNerd,代码行数:9,代码来源:LocatrFragment.java

示例13: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater menuInflater = getMenuInflater();
  menuInflater.inflate(R.menu.menu_toolbar, menu);

  MenuItem menuItemQRCode = menu.findItem(R.id.menu_items_qrcode);
  menuItemQRCode.setVisible(useToolbarActionQRCode());
  return super.onCreateOptionsMenu(menu);
}
 
开发者ID:AtlantPlatform,项目名称:atlant-android,代码行数:10,代码来源:BaseActivity.java

示例14: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.menu_home, menu);
    // Associate searchable configuration with the SearchView

    menuItemRefresh = menu.findItem(R.id.menu_refresh);
    menuItemRefresh.setVisible(false);
    menuItemNews = menu.findItem(R.id.menu_notification);
    MenuItemBadge.update(this, menuItemNews, new MenuItemBadge.Builder()
        .iconDrawable(ContextCompat.getDrawable(this, R.drawable.ic_notification_md))
        .iconTintColor(Color.WHITE)
        .textBackgroundColor(ContextCompat.getColor(this, R.color.colorAccent))
        .textColor(ContextCompat.getColor(this, R.color.colorPrimary)));
    updateNewsBadgeCount(AppManager.getInstance().newsList);

    menuItemPoints = menu.findItem(R.id.menu_points);
    MenuItemBadge.update(this, menuItemPoints, new MenuItemBadge.Builder()
            .iconDrawable(ContextCompat.getDrawable(this, R.drawable.ic_sack_md))
            .iconTintColor(Color.WHITE)
            .textBackgroundColor(ContextCompat.getColor(this, R.color.colorAccent))
            .textColor(ContextCompat.getColor(this, R.color.colorPrimary)));
    MenuItemBadge.getBadgeTextView(menuItemPoints).setText(String.valueOf(raffles_point));

    showTip();

    return true;
}
 
开发者ID:AppHero2,项目名称:Raffler-Android,代码行数:28,代码来源:MainActivity.java

示例15: onCreateOptionsMenu

import android.view.Menu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.detail, menu);
    MenuItem menuItem = menu.findItem(R.id.action_share);
    menuItem.setIntent(createShareForecastIntent());
    return true;
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:8,代码来源:DetailActivity.java


注:本文中的android.view.Menu.findItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。