當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。