Java Code Examples for android.view.MenuInflater

The following examples show how to use android.view.MenuInflater. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
    new AsyncTask<Void, Void, String>() {
        @Override
        protected String doInBackground(Void... params) {
            return MetadataDbHelper.getMetadataUriAsString(getActivity(), mClientId);
        }

        @Override
        protected void onPostExecute(String metadataUri) {
            // We only add the "Refresh" button if we have a non-empty URL to refresh from. If
            // the URL is empty, of course we can't refresh so it makes no sense to display
            // this.
            if (!TextUtils.isEmpty(metadataUri)) {
                if (mUpdateNowMenu == null) {
                    mUpdateNowMenu = menu.add(Menu.NONE, MENU_UPDATE_NOW, 0,
                                    R.string.check_for_updates_now);
                    mUpdateNowMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
                }
                refreshNetworkState();
            }
        }
    }.execute();
}
 
Example 2
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_download_details, menu);

    boolean updateIgnorePreference = XposedApp.getPreferences().getBoolean("ignore_updates", false);
    if (updateIgnorePreference) {
        SharedPreferences prefs = getSharedPreferences("update_ignored", Context.MODE_PRIVATE);

        boolean ignored = prefs.getBoolean(mModule.packageName, false);
        menu.findItem(R.id.ignoreUpdate).setChecked(ignored);
    } else {
        menu.removeItem(R.id.ignoreUpdate);
    }

    mItemBookmark = menu.findItem(R.id.menu_bookmark);
    setupBookmark(false);
    return true;
}
 
Example 3
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
  MenuInflater inflater = getActivity().getMenuInflater();

  inflater.inflate(getActionModeMenuRes(), menu);
  inflater.inflate(R.menu.conversation_list_batch, menu);

  mode.setTitle("1");

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.action_mode_status_bar));
  }

  if (Build.VERSION.SDK_INT >= 23) {
    int current = getActivity().getWindow().getDecorView().getSystemUiVisibility();
    getActivity().getWindow().getDecorView().setSystemUiVisibility(current & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
  }

  return true;
}
 
Example 4
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
        final Locale systemLocale = getResources().getConfiguration().locale;
        if (!TextUtils.isEmpty(mLocale) && !mLocale.equals(systemLocale.toString())) {
            // Hide the add button for ICS because it doesn't support specifying a locale
            // for an entry. This new "locale"-aware API has been added in conjunction
            // with the shortcut API.
            return;
        }
    }
    MenuItem actionItem =
            menu.add(0, OPTIONS_MENU_ADD, 0, R.string.user_dict_settings_add_menu_title)
            .setIcon(R.drawable.ic_menu_add);
    actionItem.setShowAsAction(
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
 
Example 5
Source Project: TDTChannels-APP   Source File: DetailChannelActivity.java    License: MIT License 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.activity_detail_channel, menu);

    boolean isItemFavorite;
    if (typeOfStream.equals(TYPE_TV)) {
        isItemFavorite = SourcesManagement.isTVChannelFavorite(channel.getName());
    } else {
        isItemFavorite = SourcesManagement.isRadioChannelFavorite(channel.getName());
    }

    if (isItemFavorite) {
        menu.getItem(0).setIcon(R.drawable.heart);
    } else {
        menu.getItem(0).setIcon(R.drawable.heart_outline);
    }
    return true;
}
 
Example 6
Source Project: Android-Keyboard   Source File: UserDictionarySettings.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (!UserDictionarySettings.IS_SHORTCUT_API_SUPPORTED) {
        final Locale systemLocale = getResources().getConfiguration().locale;
        if (!TextUtils.isEmpty(mLocale) && !mLocale.equals(systemLocale.toString())) {
            // Hide the add button for ICS because it doesn't support specifying a locale
            // for an entry. This new "locale"-aware API has been added in conjunction
            // with the shortcut API.
            return;
        }
    }
    MenuItem actionItem =
            menu.add(0, OPTIONS_MENU_ADD, 0, R.string.user_dict_settings_add_menu_title)
            .setIcon(R.drawable.ic_menu_add);
    actionItem.setShowAsAction(
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
 
Example 7
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
  MenuInflater inflater = this.getMenuInflater();
  menu.clear();

  inflater.inflate(R.menu.group_create, menu);
  super.onPrepareOptionsMenu(menu);
  return true;
}
 
Example 8
@Override
public void onPrepareOptionsMenu(Menu menu) {
  MenuInflater inflater = requireActivity().getMenuInflater();
  menu.clear();

  inflater.inflate(R.menu.text_secure_normal, menu);

  menu.findItem(R.id.menu_insights).setVisible(TextSecurePreferences.isSmsEnabled(requireContext()));
  menu.findItem(R.id.menu_clear_passphrase).setVisible(TextSecurePreferences.isPassphraseLockEnabled(requireContext()));
}
 
Example 9
Source Project: Twire   Source File: MainActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_main_activity, menu);

    return true;
}
 
Example 10
Source Project: Twire   Source File: StreamFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    optionsMenuItem = menu.findItem(R.id.menu_item_options);
    optionsMenuItem.setVisible(false);
    optionsMenuItem.setOnMenuItemClickListener(menuItem -> {
        if (mQualityButton != null) {
            mQualityButton.performClick();
        }
        return true;
    });
}
 
Example 11
Source Project: incubator-weex-playground   Source File: HistoryActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  if (historyManager.hasHistoryItems()) {
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.history, menu);
  }
  return super.onCreateOptionsMenu(menu);
}
 
Example 12
Source Project: arcusandroid   Source File: CameraNetworkFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if(menu.size() > 0){
        if (!isPopupMode) {
            menu.getItem(0).setTitle(isEditMode ? getString(R.string.card_menu_done) : getString(R.string.card_menu_edit));
        } else {
            menu.getItem(0).setTitle("");
        }
    }
    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 13
Source Project: arcusandroid   Source File: AccountBillingInfoFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (ScreenVariant.SETTINGS.equals(variant)) {
        return;
    }

    inflater.inflate(R.menu.menu_credit_card, menu);
    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 14
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    // Inflate a menu resource providing context menu items
    MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.menu_delete, menu);
    return true;
}
 
Example 15
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    // Inflate a menu resource providing context menu items
    MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.menu_delete, menu);
    return true;
}
 
Example 16
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    this.menu = menu;
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_download_history, menu);
    return true;
}
 
Example 17
Source Project: SimpleBluetoothLeTerminal   Source File: DevicesFragment.java    License: MIT License 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_devices, menu);
    this.menu = menu;
    if (bluetoothAdapter == null) {
        menu.findItem(R.id.bt_settings).setEnabled(false);
        menu.findItem(R.id.ble_scan).setEnabled(false);
    } else if(!bluetoothAdapter.isEnabled()) {
        menu.findItem(R.id.ble_scan).setEnabled(false);
    }
}
 
Example 18
Source Project: LiTr   Source File: MainActivity.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main, menu);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        // TODO implement these for pre-Marshmallow devices, if possible
        menu.removeItem(R.id.codec_list);
        menu.removeItem(R.id.avc_encoders);
        menu.removeItem(R.id.avc_decoders);
    }
    return true;
}
 
Example 19
Source Project: android_9.0.0_r45   Source File: Fragment.java    License: Apache License 2.0 5 votes vote down vote up
boolean performCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    boolean show = false;
    if (!mHidden) {
        if (mHasMenu && mMenuVisible) {
            show = true;
            onCreateOptionsMenu(menu, inflater);
        }
        if (mChildFragmentManager != null) {
            show |= mChildFragmentManager.dispatchCreateOptionsMenu(menu, inflater);
        }
    }
    return show;
}
 
Example 20
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.grid_albums, menu);

    menu.findItem(R.id.select_all).setIcon(ThemeHelper.getToolbarIcon(getContext(), GoogleMaterial.Icon.gmd_select_all));
    menu.findItem(R.id.delete).setIcon(ThemeHelper.getToolbarIcon(getContext(), (GoogleMaterial.Icon.gmd_delete)));
    menu.findItem(R.id.sort_action).setIcon(ThemeHelper.getToolbarIcon(getContext(), (GoogleMaterial.Icon.gmd_sort)));
    menu.findItem(R.id.search_action).setIcon(ThemeHelper.getToolbarIcon(getContext(), (GoogleMaterial.Icon.gmd_search)));

    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 21
@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
    final MenuItem actionItemAdd = menu.add(0, OPTIONS_MENU_ADD, 0,
            R.string.user_dict_settings_add_menu_title).setIcon(R.drawable.ic_menu_add);
    actionItemAdd.setShowAsAction(
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    final MenuItem actionItemDelete = menu.add(0, OPTIONS_MENU_DELETE, 0,
            R.string.user_dict_settings_delete).setIcon(android.R.drawable.ic_menu_delete);
    actionItemDelete.setShowAsAction(
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
 
Example 22
Source Project: openboard   Source File: SettingsFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
    if (FeedbackUtils.isHelpAndFeedbackFormSupported()) {
        menu.add(NO_MENU_GROUP, MENU_HELP_AND_FEEDBACK /* itemId */,
                MENU_HELP_AND_FEEDBACK /* order */, R.string.help_and_feedback);
    }
    final int aboutResId = FeedbackUtils.getAboutKeyboardTitleResId();
    if (aboutResId != 0) {
        menu.add(NO_MENU_GROUP, MENU_ABOUT /* itemId */, MENU_ABOUT /* order */, aboutResId);
    }
}
 
Example 23
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
    inflater.inflate(R.menu.menu_installer, menu);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
        menu.findItem(R.id.dexopt_all).setVisible(false);
        menu.findItem(R.id.speed_all).setVisible(false);
    }
}
 
Example 24
Source Project: zom-android-matrix   Source File: AccountActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_account_settings, menu);

    if (isEdit) {
        //add delete menu option
    }

    return true;
}
 
Example 25
Source Project: zom-android-matrix   Source File: ConversationView.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    // Inflate a menu resource providing context menu items
    MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.menu_message_context, menu);
    return true;
}
 
Example 26
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.logging, menu);

    menuSearch = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) menuSearch.getActionView();
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            if (adapter != null)
                adapter.getFilter().filter(getUidForName(query));
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            if (adapter != null)
                adapter.getFilter().filter(getUidForName(newText));
            return true;
        }
    });
    searchView.setOnCloseListener(new SearchView.OnCloseListener() {
        @Override
        public boolean onClose() {
            if (adapter != null)
                adapter.getFilter().filter(null);
            return true;
        }
    });

    return true;
}
 
Example 27
Source Project: lttrs-android   Source File: ThreadFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(@NonNull final Menu menu, @NonNull final MenuInflater inflater) {
    inflater.inflate(R.menu.fragment_thread, menu);
    menu.findItem(R.id.action_archive).setVisible(menuConfiguration.archive);
    final MenuItem removeLabelItem = menu.findItem(R.id.action_remove_label);
    removeLabelItem.setVisible(menuConfiguration.removeLabel);
    removeLabelItem.setTitle(getString(R.string.remove_label_x, threadViewModel.getLabel()));
    menu.findItem(R.id.action_move_to_inbox).setVisible(menuConfiguration.moveToInbox);
    menu.findItem(R.id.action_move_to_trash).setVisible(menuConfiguration.moveToTrash);
    menu.findItem(R.id.action_mark_important).setVisible(menuConfiguration.markImportant);
    menu.findItem(R.id.action_mark_not_important).setVisible(menuConfiguration.markNotImportant);
    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 28
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_settings_notifications_choose_streamers, menu);
    toggleMenuItem = menu.findItem(R.id.menu_toggle_streamers);

    if (showEnableAll != null && showEnableAll) {
        toggleMenuItem.setTitle(getString(R.string.enable_all));
    }

    return true;
}
 
Example 29
Source Project: TDTChannels-APP   Source File: RadioFragment.java    License: MIT License 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
    menuInflater.inflate(R.menu.fragment_radio, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);

    isShowingFavorites = false;

    // Change color of the search button
    if (getContext() != null) {
        Drawable drawable = DrawableCompat.wrap(searchItem.getIcon());
        DrawableCompat.setTint(drawable, ContextCompat.getColor(getContext(), R.color.white));
        menu.findItem(R.id.action_search).setIcon(drawable);
    }

    SearchView searchView = (SearchView) searchItem.getActionView();
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            // This will be fired every time you input any character.
            if (mFilter != null) {
                mFilter.filter(newText);
            }
            return false;
        }
    });
}
 
Example 30
@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
    final MenuItem actionItemAdd = menu.add(0, OPTIONS_MENU_ADD, 0,
            R.string.user_dict_settings_add_menu_title).setIcon(R.drawable.ic_menu_add);
    actionItemAdd.setShowAsAction(
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    final MenuItem actionItemDelete = menu.add(0, OPTIONS_MENU_DELETE, 0,
            R.string.user_dict_settings_delete).setIcon(android.R.drawable.ic_menu_delete);
    actionItemDelete.setShowAsAction(
            MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
 
Example 31
Source Project: Android-Keyboard   Source File: SettingsFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
    if (FeedbackUtils.isHelpAndFeedbackFormSupported()) {
        menu.add(NO_MENU_GROUP, MENU_HELP_AND_FEEDBACK /* itemId */,
                MENU_HELP_AND_FEEDBACK /* order */, R.string.help_and_feedback);
    }
    final int aboutResId = FeedbackUtils.getAboutKeyboardTitleResId();
    if (aboutResId != 0) {
        menu.add(NO_MENU_GROUP, MENU_ABOUT /* itemId */, MENU_ABOUT /* order */, aboutResId);
    }
}
 
Example 32
Source Project: media-samples   Source File: MainActivity.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.action_menu, menu);
    return true;
}
 
Example 33
Source Project: connectivity-samples   Source File: ScannerFragment.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.scanner_menu, menu);
}
 
Example 34
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.bluetooth_chat, menu);
}
 
Example 35
Source Project: candybar   Source File: RequestFragment.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_request, menu);
    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 36
Source Project: SimpleBluetoothTerminal   Source File: DevicesFragment.java    License: MIT License 4 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.menu_devices, menu);
    if(bluetoothAdapter == null)
        menu.findItem(R.id.bt_settings).setEnabled(false);
}
 
Example 37
Source Project: Twire   Source File: StreamActivity.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_stream, menu);
    return true;
}
 
Example 38
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.main_menu, menu);
}
 
Example 39
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.main_menu, menu);
}
 
Example 40
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
    inflater.inflate(R.menu.menu_app_list, menu);
    mSearchView = (SearchView) menu.findItem(R.id.app_search).getActionView();
    mSearchView.setOnQueryTextListener(mSearchListener);
}