Java Code Examples for android.view.MenuItem.isEnabled()

The following are Jave code examples for showing how to use isEnabled() of the android.view.MenuItem class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: chromium-for-android-56-debug-video   File: AppMenuAdapter.java   View Source Code Vote up 7 votes
private void setupStandardMenuItemViewHolder(StandardMenuItemViewHolder holder,
        View convertView, final MenuItem item) {
    // Set up the icon.
    Drawable icon = item.getIcon();
    holder.image.setImageDrawable(icon);
    holder.image.setVisibility(icon == null ? View.GONE : View.VISIBLE);
    holder.image.setChecked(item.isChecked());
    holder.text.setText(item.getTitle());
    holder.text.setContentDescription(item.getTitleCondensed());

    boolean isEnabled = item.isEnabled();
    // Set the text color (using a color state list).
    holder.text.setEnabled(isEnabled);
    // This will ensure that the item is not highlighted when selected.
    convertView.setEnabled(isEnabled);

    convertView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mAppMenu.onItemClick(item);
        }
    });
}
 
Example 2
Project: chromium-for-android-56-debug-video   File: AppMenu.java   View Source Code Vote up 5 votes
/**
 * Handles clicks on the AppMenu popup.
 * @param menuItem The menu item in the popup that was clicked.
 */
void onItemClick(MenuItem menuItem) {
    if (menuItem.isEnabled()) {
        if (menuItem.getItemId() == R.id.update_menu_id) {
            UpdateMenuItemHelper.getInstance().setMenuItemClicked();
        }
        dismiss();
        mHandler.onOptionsItemSelected(menuItem);
    }
}
 
Example 3
Project: SimpleRssReader   File: MainActivity.java   View Source Code Vote up 5 votes
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);
    }
}