List of usage examples for android.view Menu getItem
public MenuItem getItem(int index);
From source file:de.aw.monma.mainscreen.ActivityMainScreen.java
@Override public boolean onRecyclerItemLongClick(RecyclerView recyclerView, View view, int position, long id, int viewHolderLayoutID) { switch (viewHolderLayoutID) { case R.layout.reportlist_item: PopupMenu popUpMenu = new PopupMenu(this, view); Menu menu = popUpMenu.getMenu(); popUpMenu.getMenuInflater().inflate(R.menu.context_fragment_report_selection, menu); for (int i = 0; i < menu.size(); i++) { Intent intent = new Intent(); intent.putExtra(ID, id);/*from w w w . ja v a 2s .co m*/ menu.getItem(i).setIntent(intent); } popUpMenu.setOnMenuItemClickListener(this); popUpMenu.show(); return true; case R.layout.finanzuebersicht_item: DialogFragmentKontoEdit d = DialogFragmentKontoEdit.newInstance(new Account((int) id)); d.show(getSupportFragmentManager(), null); return true; case R.layout.hbcipassport_item: final long mID = id; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.HBCIZugangDelete); builder.setMessage(R.string.HBCIZugangDeleteMsg); builder.setPositiveButton(getString(R.string.awlib_btnAccept), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { MonMaPassport passport = new MonMaPassport(mID); passport.delete(DBHelper.getInstance()); } catch (GeschaeftsObjekt.LineNotFoundException e) { //TODO Execption bearbeiten e.printStackTrace(); } } }); builder.setNegativeButton(getString(R.string.awlib_btnCancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.create().show(); return true; default: return false; } }
From source file:com.meetingninja.csse.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { boolean drawerOpen = drawerLayout.isDrawerOpen(leftDrawerList) || drawerLayout.isDrawerOpen(rightDrawerList); for (int i = 0; i < menu.size(); i++) { menu.getItem(i).setVisible(!drawerOpen); }/* w w w . j av a 2 s. c o m*/ return super.onPrepareOptionsMenu(menu); }
From source file:com.vrem.wifianalyzer.navigation.NavigationMenuViewTest.java
@Test public void testNavigationMenuView() throws Exception { // execute//from w w w.ja v a 2 s. c om final Menu menu = navigationView.getMenu(); // validate assertEquals(NavigationMenu.values().length, menu.size()); IterableUtils.forEach(EnumUtils.values(NavigationGroup.class), new Closure<NavigationGroup>() { @Override public void execute(final NavigationGroup navigationGroup) { IterableUtils.forEach(navigationGroup.getNavigationMenus(), new Closure<NavigationMenu>() { @Override public void execute(NavigationMenu navigationMenu) { MenuItem actual = menu.getItem(navigationMenu.ordinal()); assertEquals(navigationGroup.ordinal(), actual.getGroupId()); assertEquals(mainActivity.getResources().getString(navigationMenu.getTitle()), actual.getTitle()); assertEquals(navigationMenu.ordinal(), actual.getItemId()); assertEquals(navigationMenu.ordinal(), actual.getOrder()); } }); } }); }
From source file:io.demiseq.jetreader.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); db = new JumpDatabaseHelper(MainActivity.this); initToolbar();/*from ww w .j av a2 s .c om*/ setupDrawerLayout(); progressBar.getIndeterminateDrawable().setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_ATOP); categories = db.getAllCategories(); prefs = PreferenceManager.getDefaultSharedPreferences(this); searchBox.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { toggleSearch(true); int position = temp.indexOf(adapter.getItem(i)); Intent intent = new Intent(MainActivity.this, DetailActivity.class); intent.putExtra("manga", temp.get(position)); startActivity(intent); } }); searchBox.setOnClearListener(new CustomAutoCompleteTextView.OnClearListener() { @Override public void onClear() { toggleSearch(true); } }); boolean isOpenFromNotification = getIntent().getBooleanExtra("favorite", false); if (savedInstanceState == null && !isOpenFromNotification) { GetHotMangas(); new getAllMangas().execute(); } else if (isOpenFromNotification) { GetSubscription(); new getAllMangas().execute(); NavigationView view = (NavigationView) findViewById(R.id.navigation_view); Menu menu = view.getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (item.getItemId() == R.id.drawer_feeds) { savedMenuId = item.getItemId(); item.setChecked(true); } } } else { setTitle(savedInstanceState.getString("title")); mangas = savedInstanceState.getParcelableArrayList("list"); if (mangas != null) temp = new ArrayList<>(mangas); adapter = new SearchAdapter(getApplicationContext(), R.layout.search_dropdown_item, mangas); searchBox.setAdapter(adapter); NavigationView view = (NavigationView) findViewById(R.id.navigation_view); Menu menu = view.getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); if (item.getItemId() == savedInstanceState.getInt("menu")) { savedMenuId = savedInstanceState.getInt("menu"); item.setChecked(true); } } } }
From source file:com.mishiranu.dashchan.ui.gallery.GalleryActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { for (int i = 0; i < menu.size(); i++) { menu.getItem(i).setVisible(false); }//from w w w .j a v a 2 s . co m if (!galleryMode) { PagerUnit.OptionsMenuCapabilities capabilities = pagerUnit != null ? pagerUnit.obtainOptionsMenuCapabilities() : null; if (capabilities != null && capabilities.available) { menu.findItem(OPTIONS_MENU_SAVE).setVisible(capabilities.save); menu.findItem(OPTIONS_MENU_GALLERY).setVisible(!galleryWindow && instance.galleryItems.size() > 1); menu.findItem(OPTIONS_MENU_REFRESH).setVisible(capabilities.refresh); menu.findItem(OPTIONS_MENU_TECHNICAL_INFO).setVisible(capabilities.viewTechnicalInfo); menu.findItem(OPTIONS_MENU_SEARCH_IMAGE).setVisible(capabilities.searchImage); menu.findItem(OPTIONS_MENU_COPY_LINK).setVisible(true); menu.findItem(OPTIONS_MENU_NAVIGATE_POST) .setVisible(allowNavigatePost && !scrollThread && capabilities.navigatePost); menu.findItem(OPTIONS_MENU_SHARE_LINK).setVisible(true); menu.findItem(OPTIONS_MENU_SHARE_FILE).setVisible(capabilities.shareFile); } } else { menu.findItem(OPTIONS_MENU_SELECT).setVisible(listUnit.areItemsSelectable()); } actionMenuConfigurator.onAfterPrepareOptionsMenu(menu); return true; }
From source file:com.osama.cryptofm.filemanager.ui.FilemanagerTabs.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { Log.d(TAG, "onPrepareOptionsMenu: preparing menu"); if (SharedData.IS_IN_COPY_MODE) { return super.onPrepareOptionsMenu(menu); }/*from w ww .j a v a 2s.co m*/ MenuItem item = menu.getItem(0); if (!getPreferences(Context.MODE_PRIVATE).getBoolean("layout", true)) { item.setIcon(getDrawable(R.drawable.ic_grid_view)); } return true; }
From source file:net.kw.shrdlu.grtgtfs.Activities.MenuListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { final MenuInflater inflater = getMenuInflater(); // This can be called multiple times, for difference activities, or the // action bar & nav drawer. So try process things only once, else the menus are doubled up. // Borrow this menu for a moment to expand the nav menu first. if (mDrawerItems.size() == 0) { inflater.inflate(R.menu.navdrawermenu, menu); for (int i = 0; i < menu.size(); i++) { MenuItem item = menu.getItem(i); mDrawerItems.add(new NavDrawerItem(item.getIcon(), item.getTitle(), item.getItemId())); }//from www . ja v a 2 s .c o m mNavAdapter.notifyDataSetChanged(); menu.clear(); } inflater.inflate(R.menu.actionbarmenu, menu); return super.onCreateOptionsMenu(menu); }
From source file:com.androguide.honamicontrol.soundcontrol.SoundControlFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.sound_control, menu); SharedPreferences p = fa.getSharedPreferences("SOUND_CONTROL", 0); if (p.getBoolean("LINKED", true)) menu.getItem(0).setChecked(true); else/*from w w w . j av a 2 s.c o m*/ menu.getItem(0).setChecked(false); }
From source file:com.mikhaellopez.saveinsta.activity.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); mMenuItem = menu.getItem(0); return true;// w ww .j a va2 s . co m }
From source file:dess15proj5.fau.cs.osr_amos.mobiletimerecording.ui.SelectedProjectFragment.java
/** * This method is used in the android lifecycle when the option menu is prepared. * * @param menu the menu that is prepared * methodtype initialization method/* w ww . j a v a 2s .c om*/ */ @Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); if (projectId == null && projectName == null || isSpecialProject()) { menu.getItem(0).setEnabled(false); menu.getItem(1).setEnabled(false); } }