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


Java MenuItem.setEnabled方法代码示例

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


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

示例1: onCreateOptionsMenu

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  super.onCreateOptionsMenu(menu, inflater);
  MenuItem sortItem = menu.findItem(R.id.sort);
  if (sortItem != null) {
    sortItem.setVisible(true);
    sortItem.setEnabled(true);

    if (BookmarksDBAdapter.SORT_DATE_ADDED == bookmarkPresenter.getSortOrder()) {
      MenuItem sortByDate = menu.findItem(R.id.sort_date);
      sortByDate.setChecked(true);
    } else {
      MenuItem sortByLocation = menu.findItem(R.id.sort_location);
      sortByLocation.setChecked(true);
    }

    MenuItem groupByTags = menu.findItem(R.id.group_by_tags);
    groupByTags.setChecked(bookmarkPresenter.isGroupedByTags());

    MenuItem showRecents = menu.findItem(R.id.show_recents);
    showRecents.setChecked(bookmarkPresenter.isShowingRecents());
  }
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:24,代码来源:BookmarksFragment.java

示例2: onCreateActionMode

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    menu.add(0, R.id.select_all, 0, R.string.select_all).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menu.add(0, R.id.cut, 0, R.string.cut).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    menu.add(0, R.id.copy, 0, R.string.copy).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    MenuItem pasteMenu = menu.add(0, R.id.paste, 0, R.string.paste);
    pasteMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    pasteMenu.setEnabled(fileClipboard.canPaste());

    renameMenu = menu.add(0, R.id.rename, 0, R.string.rename);
    renameMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    shareMenu = menu.add(0, R.id.share, 0, R.string.share);
    shareMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    shareActionProvider = new ShareActionProvider(context);
    shareActionProvider.setOnShareTargetSelectedListener(this);
    MenuItemCompat.setActionProvider(shareMenu, shareActionProvider);

    menu.add(0, R.id.delete, 0, R.string.delete).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    return true;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:23,代码来源:FileExplorerAction.java

示例3: onPrepareOptionsMenu

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onPrepareOptionsMenu(final Menu menu) {
    final MenuItem scanAction = menu.findItem(R.id.send_coins_options_scan);
    final PackageManager pm = activity.getPackageManager();
    scanAction.setVisible(pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)
            || pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT));
    scanAction.setEnabled(state == State.INPUT);

    final MenuItem emptyAction = menu.findItem(R.id.send_coins_options_empty);
    emptyAction.setEnabled(state == State.INPUT && paymentIntent.mayEditAmount());

    final MenuItem feeCategoryAction = menu.findItem(R.id.send_coins_options_fee_category);
    feeCategoryAction.setEnabled(state == State.INPUT);
    if (feeCategory == FeeCategory.ECONOMIC)
        menu.findItem(R.id.send_coins_options_fee_category_economic).setChecked(true);
    else if (feeCategory == FeeCategory.NORMAL)
        menu.findItem(R.id.send_coins_options_fee_category_normal).setChecked(true);
    else if (feeCategory == FeeCategory.PRIORITY)
        menu.findItem(R.id.send_coins_options_fee_category_priority).setChecked(true);

    super.onPrepareOptionsMenu(menu);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:23,代码来源:SendCoinsFragment.java

示例4: addFavorite

import android.view.MenuItem; //导入方法依赖的package包/类
private void addFavorite(String code, final MenuItem item) {
    showLoading();
    item.setEnabled(false);
    FoodApi.addFavorite(code, this.activity, new JsonCallback(this.activity) {
        public void ok(JSONObject object) {
            super.ok(object);
            item.setTitle(R.string.ia);
            item.setIcon(R.drawable.a3a);
            EventBus.getDefault().post(new FoodCollectEvent().setIsCollect(true));
        }

        public void onFinish() {
            super.onFinish();
            FoodDetailActivity.this.dismissLoading();
            if (item != null) {
                item.setEnabled(true);
            }
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:FoodDetailActivity.java

示例5: refresh

import android.view.MenuItem; //导入方法依赖的package包/类
private void refresh() {
    adapter.refresh();
    int anzahl = adapter.gibAnzahlAusgewaehlte();
    if (anzahl > 0 && menu != null) {
        MenuItem item = menu.findItem(R.id.action_speichern);
        item.setVisible(true);
        item.setEnabled(true);
    }
    if (anzahl == 1)
        getSupportActionBar().setTitle("1 Kurs ausgewählt");
    else
        getSupportActionBar().setTitle(anzahl + " Kurse ausgewählt");
}
 
开发者ID:LCA311,项目名称:leoapp-sources,代码行数:14,代码来源:AuswahlActivity.java

示例6: alterMenuItemAlpha

import android.view.MenuItem; //导入方法依赖的package包/类
private void alterMenuItemAlpha(final MenuItem item, final boolean enable) {
    if (enable) {
        if (!item.isEnabled()) {
            item.setEnabled(true);
            item.getIcon().setAlpha(ICON_ALPHA_NORMAL);
        }
    } else if (item.isEnabled()) {
        item.setEnabled(false);
        item.getIcon().setAlpha(ICON_ALPHA_LOW);
    }
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:12,代码来源:MainActivity.java

示例7: onCreateOptionsMenu

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

    //Set enabled state of done button if form is complete
    MenuItem menuItem = menu.findItem(R.id.action_done);
    if (menuItem != null) {
        boolean enabled = isFormComplete();

        menuItem.setEnabled(enabled);
        menuItem.getIcon().setAlpha(enabled ? 255 : 102);
    }

    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:KwalaGroup,项目名称:Android-Client,代码行数:16,代码来源:CreateFilterActivity2.java

示例8: onReceive

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {

    Toast toast = Toast.makeText(context,tags.get(0)+getResources().getString(R.string.down_complete), Toast.LENGTH_SHORT);
    toast.show();
    isDownloaded=true;
    MenuItem menuItem=menu.findItem( R.id.action_down);
    menuItem.setEnabled(true);
}
 
开发者ID:MuditSrivastava,项目名称:Canvas-Vision,代码行数:10,代码来源:PicDetail.java

示例9: onCreateOptionsMenu

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

    MenuItem searchItem = menu.findItem(R.id.menu_app_search);
    MenuItem filterEnabledAppsItem = menu.findItem(R.id.menu_filter_enabled);

    SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setQueryHint(getString(R.string.search_query_hint));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return recyclerViewShowSearchResult(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return recyclerViewShowSearchResult(newText);
        }
    });

    searchItem.setEnabled(false);
    filterEnabledAppsItem.setEnabled(false);
    filterEnabledAppsItem.setChecked(mShowOnlyEnabledApps);

    return true;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:28,代码来源:AppChoicesActivity.java

示例10: onPrepareOptionsMenu

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem searchItem = menu.findItem(R.id.menu_app_search);
    MenuItem filterEnabledItem = menu.findItem(R.id.menu_filter_enabled);

    if (mAdapter == null) { // cannot search yet
        searchItem.setEnabled(false);
        filterEnabledItem.setEnabled(false);
    } else {
        searchItem.setEnabled(true);
        filterEnabledItem.setEnabled(true);
    }

    return true;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:16,代码来源:AppChoicesActivity.java

示例11: setUiIsValidatingAsync

import android.view.MenuItem; //导入方法依赖的package包/类
private void setUiIsValidatingAsync(final boolean isValidating, final MenuItem saveMenuItem) {
    final ManualAddSearchEnginePreference pref =
            (ManualAddSearchEnginePreference) findPreference(getString(R.string.pref_key_manual_add_search_engine));
    pref.setProgressViewShown(isValidating);

    saveMenuItem.setEnabled(!isValidating);
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:8,代码来源:ManualAddSearchEngineSettingsFragment.java

示例12: updateBookmarkMenuItem

import android.view.MenuItem; //导入方法依赖的package包/类
/**
 * Updates the bookmark item's visibility.
 *
 * @param bookmarkMenuItem {@link MenuItem} for adding/editing the bookmark.
 * @param currentTab        Current tab being displayed.
 */
protected void updateBookmarkMenuItem(MenuItem bookmarkMenuItem, Tab currentTab) {
    bookmarkMenuItem.setEnabled(mBookmarkBridge.isEditBookmarksEnabled());
    if (currentTab.getBookmarkId() != Tab.INVALID_BOOKMARK_ID) {
        bookmarkMenuItem.setIcon(R.drawable.btn_star_filled);
        bookmarkMenuItem.setChecked(true);
        bookmarkMenuItem.setTitleCondensed(mActivity.getString(R.string.edit_bookmark));
    } else {
        bookmarkMenuItem.setIcon(R.drawable.btn_star);
        bookmarkMenuItem.setChecked(false);
        bookmarkMenuItem.setTitleCondensed(null);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:19,代码来源:AppMenuPropertiesDelegate.java

示例13: onCreateOptionsMenu

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.fragment_place_list, menu);
    
    MenuItem searchItem = menu.findItem(R.id.action_locate);
    searchItem.setEnabled(mClient.isConnected());
}
 
开发者ID:plweegie,项目名称:piast-trail,代码行数:9,代码来源:PlaceListFragment.java

示例14: onPrepareOptionsMenu

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
	Log.v(TAG, "onPrepareOptionsMenu called!");

	if (mSearchView != null) {
		//Has searchText?
		if (!mAdapter.hasSearchText()) {
			Log.d(TAG, "onPrepareOptionsMenu Clearing SearchView!");
			mSearchView.setIconified(true);// This also clears the text in SearchView widget
		} else {
			//Necessary after the restoreInstanceState
			menu.findItem(R.id.action_search).expandActionView();//must be called first
			//This restores the text, must be after the expandActionView()
			mSearchView.setQuery(mAdapter.getSearchText(), false);//submit = false!!!
			mSearchView.clearFocus();//Optionally the keyboard can be closed
			//mSearchView.setIconified(false);//This is not necessary
		}
	}
	// Fast Scroller
	MenuItem fastScrollerItem = menu.findItem(R.id.action_fast_scroller);
	if (fastScrollerItem != null) {
		fastScrollerItem.setChecked(mAdapter.isFastScrollerEnabled());
	}
	// Animate on update?
	MenuItem animateUpdateMenuItem = menu.findItem(R.id.action_animate_on_update);
	if (animateUpdateMenuItem != null) {
		animateUpdateMenuItem.setChecked(DatabaseConfiguration.animateOnUpdate);
	}
	// Headers are shown?
	MenuItem headersMenuItem = menu.findItem(R.id.action_show_hide_headers);
	if (headersMenuItem != null) {
		headersMenuItem.setTitle(mAdapter.areHeadersShown() ? R.string.hide_headers : R.string.show_headers);
	}
	// Sticky Header item?
	MenuItem stickyItem = menu.findItem(R.id.action_sticky_headers);
	if (stickyItem != null) {
		stickyItem.setEnabled(mAdapter.areHeadersShown());
		stickyItem.setChecked(mAdapter.areHeadersSticky());
	}
	// Scrolling Animations?
	MenuItem animationMenuItem = menu.findItem(R.id.action_animation);
	if (animationMenuItem != null) {
		animationMenuItem.setChecked(DatabaseConfiguration.animateOnScrolling);
	}
	// Reverse scrolling animation?
	MenuItem reverseMenuItem = menu.findItem(R.id.action_reverse);
	if (reverseMenuItem != null) {
		reverseMenuItem.setEnabled(mAdapter.isAnimationOnScrollingEnabled());
		reverseMenuItem.setChecked(mAdapter.isAnimationOnReverseScrollingEnabled());
	}
	// DiffUtil?
	MenuItem diffUtilItem = menu.findItem(R.id.action_diff_util);
	if (diffUtilItem != null) {
		diffUtilItem.setChecked(DatabaseConfiguration.animateWithDiffUtil);
	}
	return super.onPrepareOptionsMenu(menu);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:58,代码来源:MainActivity.java

示例15: onOptionsItemSelected

import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    UserController controller;
    switch (id) {
        case R.id.action_delete:
            controller = UserController.getInstance(this);
            controller.deleteCurrentProfile();

            if (controller.userCount() == 1) {
                item.setEnabled(false);
            }

            setResult(RESULT_OK);
            finish();
            return true;

        case R.id.action_add:
            // Sync any changed settings.
            controller = UserController.getInstance(this);
            controller.syncActiveProfile();
            // Add the new profile, changing the current profile.
            controller.addNewProfile();
            // Restart this activity, to force a re-load by all frames.
            startActivity(new Intent(SettingsActivity.this, SettingsActivity.class));
            // Close this instance of this activity.
            finish();
            return true;

        case R.id.action_switch:
            // Sync any changed settings.
            controller = UserController.getInstance(this);
            controller.syncActiveProfile();

            // Goto the switch activity
            startActivity(new Intent(SettingsActivity.this, SwitchProfileActivity.class));

            // Close this  activity.
            finish();
            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
开发者ID:nelladragon,项目名称:scab,代码行数:49,代码来源:SettingsActivity.java


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