Java Code Examples for android.view.Menu#setGroupCheckable()
The following examples show how to use
android.view.Menu#setGroupCheckable() .
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: WalletActivity.java From xmrwallet with Apache License 2.0 | 6 votes |
void updateAccountsList() { final Wallet wallet = getWallet(); Menu menu = accountsView.getMenu(); menu.removeGroup(R.id.accounts_list); final int n = wallet.getNumAccounts(); final boolean showBalances = (n > 1) && !isStreetMode(); for (int i = 0; i < n; i++) { final String label = (showBalances ? getString(R.string.label_account, wallet.getAccountLabel(i), Helper.getDisplayAmount(wallet.getBalance(i), 2)) : wallet.getAccountLabel(i)); final MenuItem item = menu.add(R.id.accounts_list, getAccountId(i), 2 * i, label); item.setIcon(R.drawable.ic_account_balance_wallet_black_24dp); if (i == wallet.getAccountIndex()) item.setChecked(true); } menu.setGroupCheckable(R.id.accounts_list, true, true); }
Example 2
Source File: DailyReportFragment.java From privacy-friendly-pedometer with GNU General Public License v3.0 | 6 votes |
@Override public void inflateWalkingModeMenu(Menu menu) { // Add the walking modes to option menu menu.clear(); menuWalkingModes = new HashMap<>(); List<WalkingMode> walkingModes = WalkingModePersistenceHelper.getAllItems(getContext()); int i = 0; for (WalkingMode walkingMode : walkingModes) { int id = Menu.FIRST + (i++); menuWalkingModes.put(id, walkingMode); menu.add(0, id, Menu.NONE, walkingMode.getName()).setChecked(walkingMode.isActive()); } menu.add(1, Menu.FIRST + i, Menu.NONE, getString(R.string.correct_steps)).setCheckable(false); menuCorrectStepId = Menu.FIRST + i; menu.setGroupCheckable(0, true, true); }
Example 3
Source File: WaypointList.java From Androzic with GNU General Public License v3.0 | 6 votes |
@Override public void onPrepareOptionsMenu(final Menu menu) { Androzic application = Androzic.getApplication(); MenuItem sortItem = menu.findItem(mSortMode == 0 ? R.id.action_sort_alpha : R.id.action_sort_size); sortItem.setChecked(true); Editor editor = PreferenceManager.getDefaultSharedPreferences(application).edit(); editor.putInt(getString(R.string.wpt_sort), mSortMode); editor.commit(); List<WaypointSet> sets = application.getWaypointSets(); if (sets.size() > 1) { menu.setGroupVisible(R.id.group_sets, true); menu.removeGroup(R.id.group_sets); for (int i = 1; i < sets.size(); i++) menu.add(R.id.group_sets, i, Menu.NONE, sets.get(i).name).setChecked(true); menu.setGroupCheckable(R.id.group_sets, true, false); } }
Example 4
Source File: PlayerActivity.java From Exoplayer_VLC with Apache License 2.0 | 6 votes |
public void showVerboseLogPopup(View v) { PopupMenu popup = new PopupMenu(this, v); Menu menu = popup.getMenu(); menu.add(Menu.NONE, 0, Menu.NONE, R.string.logging_normal); menu.add(Menu.NONE, 1, Menu.NONE, R.string.logging_verbose); menu.setGroupCheckable(Menu.NONE, true, true); menu.findItem((VerboseLogUtil.areAllTagsEnabled()) ? 1 : 0).setChecked(true); popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == 0) { VerboseLogUtil.setEnableAllTags(false); } else { VerboseLogUtil.setEnableAllTags(true); } return true; } }); popup.show(); }
Example 5
Source File: PlayerActivity.java From Android-Example-HLS-ExoPlayer with Apache License 2.0 | 6 votes |
public void showVerboseLogPopup(View v) { PopupMenu popup = new PopupMenu(this, v); Menu menu = popup.getMenu(); menu.add(Menu.NONE, 0, Menu.NONE, R.string.logging_normal); menu.add(Menu.NONE, 1, Menu.NONE, R.string.logging_verbose); menu.setGroupCheckable(Menu.NONE, true, true); menu.findItem((VerboseLogUtil.areAllTagsEnabled()) ? 1 : 0).setChecked(true); popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == 0) { VerboseLogUtil.setEnableAllTags(false); } else { VerboseLogUtil.setEnableAllTags(true); } return true; } }); popup.show(); }
Example 6
Source File: ExVidPlayerImp.java From ExVidPlayer with Apache License 2.0 | 5 votes |
@Override public void setQuality(View v) { PopupMenu popup = new PopupMenu(activity, v); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { player.setSelectedTrack(0, (item.getItemId() - 1)); return false; } }); ArrayList<Integer> formats = new ArrayList<>(); Menu menu = popup.getMenu(); menu.add(Menu.NONE, 0, 0, "Bitrate"); for (int i = 0; i < player.getTrackCount(0); i++) { MediaFormat format = player.getTrackFormat(0, i); if (MimeTypes.isVideo(format.mimeType)) { Log.e("dsa", format.bitrate + ""); if (format.adaptive) { menu.add(1, (i + 1), (i + 1), "Auto"); } else { if (!formats.contains(format.bitrate)) { menu.add(1, (i + 1), (i + 1), (format.bitrate) / 1000 + " kbps"); formats.add(format.bitrate); } } } } menu.setGroupCheckable(1, true, true); menu.findItem((player.getSelectedTrack(0) + 1)).setChecked(true); popup.show(); }
Example 7
Source File: CollectionCoverSearchFragment.java From Mizuu with Apache License 2.0 | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { for (int i = 0; i < mItems.length; i++) menu.add(0, i, i, mItems[i]); menu.setGroupCheckable(0, true, true); super.onCreateOptionsMenu(menu, inflater); }
Example 8
Source File: CoverSearchFragment.java From Mizuu with Apache License 2.0 | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { for (int i = 0; i < mItems.length; i++) menu.add(0, i, i, mItems[i]); menu.setGroupCheckable(0, true, true); super.onCreateOptionsMenu(menu, inflater); }
Example 9
Source File: FanartSearchFragment.java From Mizuu with Apache License 2.0 | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { for (int i = 0; i < mItems.length; i++) menu.add(1, i, i, mItems[i]); menu.setGroupCheckable(1, true, true); super.onCreateOptionsMenu(menu, inflater); }
Example 10
Source File: PlayerActivity.java From Exoplayer_VLC with Apache License 2.0 | 5 votes |
private void configurePopupWithTracks(PopupMenu popup, final OnMenuItemClickListener customActionClickListener, final int trackType) { if (player == null) { return; } String[] tracks = player.getTracks(trackType); if (tracks == null) { return; } popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return (customActionClickListener != null && customActionClickListener.onMenuItemClick(item)) || onTrackItemClick(item, trackType); } }); Menu menu = popup.getMenu(); // ID_OFFSET ensures we avoid clashing with Menu.NONE (which equals 0) menu.add(MENU_GROUP_TRACKS, DemoPlayer.DISABLED_TRACK + ID_OFFSET, Menu.NONE, R.string.off); if (tracks.length == 1 && TextUtils.isEmpty(tracks[0])) { menu.add(MENU_GROUP_TRACKS, DemoPlayer.PRIMARY_TRACK + ID_OFFSET, Menu.NONE, R.string.on); } else { for (int i = 0; i < tracks.length; i++) { menu.add(MENU_GROUP_TRACKS, i + ID_OFFSET, Menu.NONE, tracks[i]); } } menu.setGroupCheckable(MENU_GROUP_TRACKS, true, true); menu.findItem(player.getSelectedTrackIndex(trackType) + ID_OFFSET).setChecked(true); }
Example 11
Source File: PlayerActivity.java From Android-Example-HLS-ExoPlayer with Apache License 2.0 | 5 votes |
private void configurePopupWithTracks(PopupMenu popup, final OnMenuItemClickListener customActionClickListener, final int trackType) { if (player == null) { return; } int trackCount = player.getTrackCount(trackType); if (trackCount == 0) { return; } popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return (customActionClickListener != null && customActionClickListener.onMenuItemClick(item)) || onTrackItemClick(item, trackType); } }); Menu menu = popup.getMenu(); // ID_OFFSET ensures we avoid clashing with Menu.NONE (which equals 0). menu.add(MENU_GROUP_TRACKS, DemoPlayer.TRACK_DISABLED + ID_OFFSET, Menu.NONE, R.string.off); for (int i = 0; i < trackCount; i++) { menu.add(MENU_GROUP_TRACKS, i + ID_OFFSET, Menu.NONE, buildTrackName(player.getTrackFormat(trackType, i))); } menu.setGroupCheckable(MENU_GROUP_TRACKS, true, true); menu.findItem(player.getSelectedTrack(trackType) + ID_OFFSET).setChecked(true); }
Example 12
Source File: DistanceMeasurementActivity.java From privacy-friendly-pedometer with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPrepareOptionsMenu(Menu menu) { // Add the walking modes to option menu menu.clear(); menuWalkingModes = new HashMap<>(); List<WalkingMode> walkingModes = WalkingModePersistenceHelper.getAllItems(this); int i = 0; for (WalkingMode walkingMode : walkingModes) { int id = Menu.FIRST + (i++); menuWalkingModes.put(id, walkingMode); menu.add(0, id, Menu.NONE, walkingMode.getName()).setChecked(walkingMode.isActive()); } menu.setGroupCheckable(0, true, true); return super.onPrepareOptionsMenu(menu); }
Example 13
Source File: TrainingOverviewActivity.java From privacy-friendly-pedometer with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPrepareOptionsMenu(Menu menu) { // Add the walking modes to option menu menu.clear(); menuWalkingModes = new HashMap<>(); List<WalkingMode> walkingModes = WalkingModePersistenceHelper.getAllItems(this); int i = 0; for (WalkingMode walkingMode : walkingModes) { int id = Menu.FIRST + (i++); menuWalkingModes.put(id, walkingMode); menu.add(0, id, Menu.NONE, walkingMode.getName()).setChecked(walkingMode.isActive()); } menu.setGroupCheckable(0, true, true); return super.onPrepareOptionsMenu(menu); }
Example 14
Source File: TrainingActivity.java From privacy-friendly-pedometer with GNU General Public License v3.0 | 5 votes |
@Override public boolean onPrepareOptionsMenu(Menu menu) { // Add the walking modes to option menu menu.clear(); menuWalkingModes = new HashMap<>(); List<WalkingMode> walkingModes = WalkingModePersistenceHelper.getAllItems(this); int i = 0; for (WalkingMode walkingMode : walkingModes) { int id = Menu.FIRST + (i++); menuWalkingModes.put(id, walkingMode); menu.add(0, id, Menu.NONE, walkingMode.getName()).setChecked(walkingMode.isActive()); } menu.setGroupCheckable(0, true, true); return super.onPrepareOptionsMenu(menu); }
Example 15
Source File: WeeklyReportFragment.java From privacy-friendly-pedometer with GNU General Public License v3.0 | 5 votes |
@Override public void inflateWalkingModeMenu(Menu menu) { // Add the walking modes to option menu menu.clear(); menuWalkingModes = new HashMap<>(); List<WalkingMode> walkingModes = WalkingModePersistenceHelper.getAllItems(getContext()); int i = 0; for (WalkingMode walkingMode : walkingModes) { int id = Menu.FIRST + (i++); menuWalkingModes.put(id, walkingMode); menu.add(0, id, Menu.NONE, walkingMode.getName()).setChecked(walkingMode.isActive()); } menu.setGroupCheckable(0, true, true); }
Example 16
Source File: MonthlyReportFragment.java From privacy-friendly-pedometer with GNU General Public License v3.0 | 5 votes |
@Override public void inflateWalkingModeMenu(Menu menu) { // Add the walking modes to option menu menu.clear(); menuWalkingModes = new HashMap<>(); List<WalkingMode> walkingModes = WalkingModePersistenceHelper.getAllItems(getContext()); int i = 0; for (WalkingMode walkingMode : walkingModes) { int id = Menu.FIRST + (i++); menuWalkingModes.put(id, walkingMode); menu.add(0, id, Menu.NONE, walkingMode.getName()).setChecked(walkingMode.isActive()); } menu.setGroupCheckable(0, true, true); }
Example 17
Source File: StatisticsFragment.java From privacy-friendly-interval-timer with GNU General Public License v3.0 | 4 votes |
@Override public void onPrepareOptionsMenu(Menu menu) { menu.clear(); menu.setGroupCheckable(0, true, true); super.onPrepareOptionsMenu(menu); }
Example 18
Source File: MainActivity.java From Anecdote with Apache License 2.0 | 4 votes |
private void populateNavigationView(boolean addNewNotification) { // Setup NavigationView final Menu navigationViewMenu = mNavigationView.getMenu(); navigationViewMenu.clear(); for (final Website website : mWebsites) { final ImageButton imageButton = (ImageButton) navigationViewMenu .add(R.id.drawer_group_content, Menu.NONE, Menu.NONE, website.name) .setActionView(R.layout.navigationview_actionlayout) .getActionView(); imageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PopupMenu popup = new PopupMenu(MainActivity.this, imageButton); //Inflating the Popup using xml file popup.getMenuInflater() .inflate(R.menu.website_popup, popup.getMenu()); //registering popup with OnMenuItemClickListener popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_edit: // Remove edit button for remote website if (!website.isEditable()) { Toast.makeText( MainActivity.this, R.string.action_website_noteditable_toast, Toast.LENGTH_SHORT) .show(); return false; } openWebsiteDialog(website); break; case R.id.action_delete: SpStorage.deleteWebsite(MainActivity.this, website); EventBus.getDefault().post(new WebsitesChangeEvent()); EventTracker.trackWebsiteDelete(website.name); break; case R.id.action_default: SpStorage.setDefaultWebsite(MainActivity.this, website); EventBus.getDefault().post(new WebsitesChangeEvent()); EventTracker.trackWebsiteDefault(website.name); break; default: Toast.makeText( MainActivity.this, R.string.not_implemented, Toast.LENGTH_SHORT) .show(); break; } return true; } }); popup.show(); } }); } navigationViewMenu.add(R.id.drawer_group_favorites, Menu.NONE, Menu.NONE, R.string.action_favoris) .setIcon(R.drawable.ic_favorite_white_24dp); navigationViewMenu.setGroupCheckable(R.id.drawer_group_favorites, true, true); navigationViewMenu.add(R.id.drawer_group_action, Menu.NONE, Menu.NONE, R.string.action_website_add) .setIcon(R.drawable.ic_add_white_24dp); if (addNewNotification) { navigationViewMenu .add(R.id.drawer_group_action, Menu.NONE, Menu.NONE, R.string.action_website_newwebsite) .setIcon(R.drawable.ic_info_outline_white_24dp); } navigationViewMenu.setGroupCheckable(R.id.drawer_group_content, true, true); navigationViewMenu.getItem(0).setChecked(true); }