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