Java Code Examples for android.view.Menu#findItem()

The following examples show how to use android.view.Menu#findItem() . 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 check out the related API usage on the sidebar.
Example 1
Source File: TrackListActivity.java    From mytracks with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.track_list, menu);

  menu.findItem(R.id.track_list_help_feedback).setTitle(
      ApiAdapterFactory.getApiAdapter().isGoogleFeedbackAvailable() ? R.string.menu_help_feedback
          : R.string.menu_help);

  searchMenuItem = menu.findItem(R.id.track_list_search);
  ApiAdapterFactory.getApiAdapter().configureSearchWidget(this, searchMenuItem, trackController);

  startGpsMenuItem = menu.findItem(R.id.track_list_start_gps);
  playMultipleItem = menu.findItem(R.id.track_list_play_mutliple);
  syncNowMenuItem = menu.findItem(R.id.track_list_sync_now);
  aggregatedStatisticsMenuItem = menu.findItem(R.id.track_list_aggregated_statistics);
  exportAllMenuItem = menu.findItem(R.id.track_list_export_all);
  importAllMenuItem = menu.findItem(R.id.track_list_import_all);
  deleteAllMenuItem = menu.findItem(R.id.track_list_delete_all);

  return super.onCreateOptionsMenu(menu);
}
 
Example 2
Source File: Home.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_home, menu);

    //wear integration
    if (!mPreferences.getBoolean("wear_sync", false)) {
        menu.removeItem(R.id.action_open_watch_settings);
        menu.removeItem(R.id.action_resend_last_bg);
    }

    //speak readings
    MenuItem menuItem =  menu.findItem(R.id.action_toggle_speakreadings);
    if(mPreferences.getBoolean("bg_to_speech_shortcut", false)){
        menuItem.setVisible(true);
        if(mPreferences.getBoolean("bg_to_speech", false)){
            menuItem.setChecked(true);
        } else {
            menuItem.setChecked(false);
        }
    } else {
        menuItem.setVisible(false);
    }
    return super.onCreateOptionsMenu(menu);
}
 
Example 3
Source File: ContactSelectionActivity.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.group_create_menu, menu);
    menu.removeItem(R.id.Next);
    if (disableCheckBox) {
        menu.removeItem(R.id.Done);
    }
    MenuItem searchItem = menu.findItem(R.id.menu_search);
    searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setQueryHint(getResources().getString(R.string.search_hint));
    if (Utils.hasICS()) {
        searchItem.collapseActionView();
    }
    searchView.setOnQueryTextListener(this);
    searchView.setIconified(true);
    return super.onCreateOptionsMenu(menu);
}
 
Example 4
Source File: HomeFragment.java    From guanggoo-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.home, menu);

    final MenuItem menuItemNotification = menu.findItem(R.id.action_notifications);
    MenuItemBadge.update(getActivity(), menuItemNotification, new MenuItemBadge.Builder()
            .iconDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.ic_menu_notifications))
            .iconTintColor(Color.WHITE));

    App.getInstance().mGlobal.hasNotifications.observe(this, new Observer<Boolean>() {
        @Override
        public void onChanged(@Nullable Boolean aBoolean) {
            if (aBoolean) {
                MenuItemBadge.getBadgeTextView(menuItemNotification).setHighLightMode(true);
            } else {
                MenuItemBadge.getBadgeTextView(menuItemNotification).clearHighLightMode();
            }
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 5
Source File: TrustActivity.java    From trust with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);
    MenuItem toggle = menu.findItem(R.id.starttracking);
    if (toggle != null) {
        if (!isMyServiceRunning()) {
            toggle.setTitle(R.string.run);
            toggle.setIcon(R.drawable.ic_action_playback_play);
        } else {
            toggle.setTitle(R.string.stop);
            toggle.setIcon(R.drawable.ic_action_playback_pause);
        }
    }
    return super.onCreateOptionsMenu(menu);
}
 
Example 6
Source File: LocationSettingsBaseFragment.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onPrepareOptionsMenu (Menu menu)
{
    super.onPrepareOptionsMenu(menu);
    MenuItem mi = menu.findItem(R.id.confirm);
    mi.setVisible(!_propertiesView.isInstantSave());
    mi.setEnabled(isValidData());
}
 
Example 7
Source File: SearchListActivity.java    From mytracks with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.search_list, menu);
  searchMenuItem = menu.findItem(R.id.search_list_search);
  ApiAdapterFactory.getApiAdapter().configureSearchWidget(this, searchMenuItem, null);
  return super.onCreateOptionsMenu(menu);
}
 
Example 8
Source File: BrowsePostActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
	MenuItem item = menu.findItem(R.id.menuMyPosts);
       if (MainActivity.user == null) {
       	item.setEnabled(false);
       }
    return true;
}
 
Example 9
Source File: ChooseCountryActivity.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.choose_country, menu);
    final MenuItem menuSearchView = menu.findItem(R.id.action_search);
    final View mSearchView = menuSearchView.getActionView();
    mSearchEditText = mSearchView.findViewById(R.id.search_field);
    mSearchEditText.addTextChangedListener(mSearchTextWatcher);
    mSearchEditText.setHint(R.string.search_countries);
    mSearchEditText.setOnEditorActionListener(mSearchDone);
    menuSearchView.setOnActionExpandListener(mOnActionExpandListener);
    return true;
}
 
Example 10
Source File: StartConversationActivity.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	getMenuInflater().inflate(R.menu.start_conversation, menu);
	AccountUtils.showHideMenuItems(menu);
	MenuItem menuHideOffline = menu.findItem(R.id.action_hide_offline);
	MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code);
	qrCodeScanMenuItem.setVisible(isCameraFeatureAvailable());
	if (QuickConversationsService.isQuicksy()) {
		menuHideOffline.setVisible(false);
	} else {
		menuHideOffline.setVisible(true);
		menuHideOffline.setChecked(this.mHideOfflineContacts);
	}
	mMenuSearchView = menu.findItem(R.id.action_search);
	mMenuSearchView.setOnActionExpandListener(mOnActionExpandListener);
	View mSearchView = mMenuSearchView.getActionView();
	mSearchEditText = mSearchView.findViewById(R.id.search_field);
	mSearchEditText.addTextChangedListener(mSearchTextWatcher);
	mSearchEditText.setOnEditorActionListener(mSearchDone);
	String initialSearchValue = mInitialSearchValue.pop();
	if (initialSearchValue != null) {
		mMenuSearchView.expandActionView();
		mSearchEditText.append(initialSearchValue);
		filter(initialSearchValue);
	}
	updateSearchViewHint();
	return super.onCreateOptionsMenu(menu);
}
 
Example 11
Source File: PreferenceActivity.java    From habpanelviewer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.preferences_toolbar_menu, menu);
    mUpItem = menu.findItem(R.id.action_back);

    return true;
}
 
Example 12
Source File: MainChatActivity.java    From twiliochat-android with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.main_chat, menu);
  this.leaveChannelMenuItem = menu.findItem(R.id.action_leave_channel);
  this.leaveChannelMenuItem.setVisible(false);
  this.deleteChannelMenuItem = menu.findItem(R.id.action_delete_channel);
  this.deleteChannelMenuItem.setVisible(false);
  return true;
}
 
Example 13
Source File: MobiComKitPeopleActivity.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_contact, menu);
    MenuItem searchItem = menu.findItem(R.id.menu_search);
    searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setQueryHint(getResources().getString(R.string.search_hint));
    if (Utils.hasICS()) {
        searchItem.collapseActionView();
    }
    searchView.setOnQueryTextListener(this);
    searchView.setSubmitButtonEnabled(true);
    searchView.setIconified(true);
    return super.onCreateOptionsMenu(menu);
}
 
Example 14
Source File: DetailActivity.java    From android-dev-challenge with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 15
Source File: ActManageActivity.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.menu_thread_reply, menu);
    mMenuItem = menu.findItem(R.id.action_send);
    mMenuItem.setTitle(R.string.z_act_top_btn_commit);
    if (fragment_type == 1) {
        mMenuItem.setVisible(true);
    } else {
        mMenuItem.setVisible(false);
    }
    return true;
}
 
Example 16
Source File: FileExplorerActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.explorer_menu, menu);

    Pref pref = Pref.getInstance(this);
    menu.findItem(R.id.show_hidden_files_menu).setChecked(pref.isShowHiddenFiles());
    pasteMenu = menu.findItem(R.id.paste_menu);

    int sortId;
    switch (pref.getFileSortType()) {
        case FileListSorter.SORT_DATE:
            sortId = R.id.sort_by_datetime_menu;
            break;
        case FileListSorter.SORT_SIZE:
            sortId = R.id.sort_by_size_menu;
            break;
        case FileListSorter.SORT_TYPE:
            sortId = R.id.sort_by_type_menu;
            break;
        default:
            sortId = R.id.sort_by_name_menu;
            break;
    }

    menu.findItem(sortId).setChecked(true);

    return super.onCreateOptionsMenu(menu);
}
 
Example 17
Source File: DetailActivity.java    From android-dev-challenge with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 18
Source File: MovieListFragment.java    From Kore with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (!isAdded()) {
        // HACK: Fix crash reported on Play Store. Why does this is necessary is beyond me
        super.onCreateOptionsMenu(menu, inflater);
        return;
    }

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

    // Setup filters
    MenuItem hideWatched = menu.findItem(R.id.action_hide_watched),
            ignoreArticles = menu.findItem(R.id.action_ignore_prefixes),
            sortByName = menu.findItem(R.id.action_sort_by_name),
            sortByYear = menu.findItem(R.id.action_sort_by_year),
            sortByRating = menu.findItem(R.id.action_sort_by_rating),
            sortByDateAdded = menu.findItem(R.id.action_sort_by_date_added),
            sortByLastPlayed = menu.findItem(R.id.action_sort_by_last_played),
            sortByLength = menu.findItem(R.id.action_sort_by_length),
            showWatchedStatusMenuItem = menu.findItem(R.id.action_show_watched_status),
            showRatingMenuItem = menu.findItem(R.id.action_show_rating);

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    hideWatched.setChecked(preferences.getBoolean(Settings.KEY_PREF_MOVIES_FILTER_HIDE_WATCHED, Settings.DEFAULT_PREF_MOVIES_FILTER_HIDE_WATCHED));
    showWatchedStatusMenuItem.setChecked(preferences.getBoolean(Settings.KEY_PREF_MOVIES_SHOW_WATCHED_STATUS, Settings.DEFAULT_PREF_MOVIES_SHOW_WATCHED_STATUS));
    ignoreArticles.setChecked(preferences.getBoolean(Settings.KEY_PREF_MOVIES_IGNORE_PREFIXES, Settings.DEFAULT_PREF_MOVIES_IGNORE_PREFIXES));
    showRatingMenuItem.setChecked(preferences.getBoolean(Settings.KEY_PREF_MOVIES_SHOW_RATING, Settings.DEFAULT_PREF_MOVIES_SHOW_RATING));

    int sortOrder = preferences.getInt(Settings.KEY_PREF_MOVIES_SORT_ORDER, Settings.DEFAULT_PREF_MOVIES_SORT_ORDER);
    switch (sortOrder) {
        case Settings.SORT_BY_YEAR:
            sortByYear.setChecked(true);
            break;
        case Settings.SORT_BY_RATING:
            sortByRating.setChecked(true);
            break;
        case Settings.SORT_BY_DATE_ADDED:
            sortByDateAdded.setChecked(true);
            break;
        case Settings.SORT_BY_LAST_PLAYED:
            sortByLastPlayed.setChecked(true);
            break;
        case Settings.SORT_BY_LENGTH:
            sortByLength.setChecked(true);
            break;
        default:
            sortByName.setChecked(true);
            break;
    }

    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 19
Source File: PreviewTextFragment.java    From Cirrus_depricated with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    menu.findItem(R.id.action_search).setVisible(false);
    menu.findItem(R.id.action_changeView).setVisible(false);

    if (mContainerActivity.getStorageManager() != null) {
        FileMenuFilter mf = new FileMenuFilter(
                getFile(),
                mContainerActivity.getStorageManager().getAccount(),
                mContainerActivity,
                getActivity()
        );
        mf.filter(menu);
    }

    // additional restriction for this fragment
    MenuItem item = menu.findItem(R.id.action_rename_file);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }

    // additional restriction for this fragment
    item = menu.findItem(R.id.action_move);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }

    // this one doesn't make sense since the file has to be down in order to be previewed
    item = menu.findItem(R.id.action_download_file);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }

    item = menu.findItem(R.id.action_sync_file);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }

    /*item = menu.findItem(R.id.action_sync_account);
    if (item != null) {
        item.setVisible(false);
        item.setEnabled(false);
    }*/
}
 
Example 20
Source File: DragActivity.java    From PracticalRecyclerView with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem grid = menu.findItem(R.id.action_grid);
    grid.setChecked(gridChecked);
    return true;
}