List of usage examples for android.view Menu findItem
public MenuItem findItem(int id);
From source file:azad.hallaji.farzad.com.masirezendegi.PageVirayesh.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_page_virayesh); Fabric.with(this, new Crashlytics()); TextView virayeshTextinToolbar = (TextView) findViewById(R.id.virayeshTextinToolbar); final TextView zaxireTextinToolbar = (TextView) findViewById(R.id.zaxireTextinToolbar); init();/*from www . j av a2s . c om*/ ableall(false); drawer = (DrawerLayout) findViewById(R.id.drawer_layout); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); ImageView imageView = (ImageView) findViewById(R.id.menuButton); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { drawer.openDrawer(Gravity.END); } }); if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) { Menu nav_Menu = navigationView.getMenu(); nav_Menu.findItem(R.id.nav_marakez).setVisible(true); nav_Menu.findItem(R.id.nav_profile).setVisible(true); nav_Menu.findItem(R.id.nav_login).setVisible(false); nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true); nav_Menu.findItem(R.id.nav_porseshha).setVisible(true); nav_Menu.findItem(R.id.nav_logout).setVisible(true); } else { Menu nav_Menu = navigationView.getMenu(); nav_Menu.findItem(R.id.nav_marakez).setVisible(true); nav_Menu.findItem(R.id.nav_profile).setVisible(false); nav_Menu.findItem(R.id.nav_login).setVisible(true); nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true); nav_Menu.findItem(R.id.nav_porseshha).setVisible(true); nav_Menu.findItem(R.id.nav_logout).setVisible(false); } final ImageView imageView1 = (ImageView) findViewById(R.id.onclickeasadinchimastanxanim); imageView1.setVisibility(View.GONE); if (isOnline()) { setAlage(); if (GlobalVar.getUserType().equals("adviser")) { virayeshTextinToolbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ableall(true); sihhhhh1.setVisibility(View.VISIBLE); sihhhhh2.setVisibility(View.VISIBLE); imageView1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent pickPhoto = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(pickPhoto, 1);//one can be replaced with any action code } }); zaxireTextinToolbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { postgetData(); } }); } }); imageView1.setVisibility(View.VISIBLE); barchasbEdit.setVisibility(View.VISIBLE); costperminEdit.setVisibility(View.VISIBLE); maxtimeEdit.setVisibility(View.VISIBLE); sexEdit.setVisibility(View.VISIBLE); dialtecEdit.setVisibility(View.VISIBLE); aboutmeEdit.setVisibility(View.VISIBLE); } else if (GlobalVar.getUserType().equals("user")) { virayeshTextinToolbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TextView textView = (TextView) findViewById(R.id.sihhhhh1); TextView textView2 = (TextView) findViewById(R.id.sihhhhh2); textView.setVisibility(View.GONE); textView2.setVisibility(View.GONE); imageView1.setVisibility(View.VISIBLE); boolean b = false; sihhhhh1.setVisibility(View.GONE); sihhhhh2.setVisibility(View.GONE); namexanivadeEdit.setEnabled(!b); shomareteleEdit.setEnabled(!b); emailEdit.setEnabled(!b); barchasbEdit.setVisibility(View.GONE); costperminEdit.setVisibility(View.GONE); maxtimeEdit.setVisibility(View.GONE); sexEdit.setVisibility(View.GONE); dialtecEdit.setVisibility(View.GONE); aboutmeEdit.setVisibility(View.GONE); imageView1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent pickPhoto = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(pickPhoto, 1);//one can be replaced with any action code } }); zaxireTextinToolbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { postgetData(); } }); } }); } } else { Toast.makeText(getApplicationContext(), "Network isn't available", Toast.LENGTH_LONG).show(); } }
From source file:com.scigames.slidegame.Registration2RFIDActivity.java
/** * Called right before your activity's option menu is displayed. *///from w ww.ja v a2 s. c o m @Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); // Before showing the menu, we need to decide whether the clear // item is enabled depending on whether there is text to clear. // menu.findItem(CLEAR_ID).setVisible(firstName.getText().length() > 0); // menu.findItem(CLEAR_ID).setVisible(lastName.getText().length() > 0); menu.findItem(CLEAR_ID).setVisible(braceletId.getText().length() > 0); return true; }
From source file:com.andrewshu.android.reddit.submit.SubmitLinkActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); if (mCaptchaUrl == null) menu.findItem(R.id.update_captcha_menu_id).setVisible(false); else/*from w w w.jav a 2s. c o m*/ menu.findItem(R.id.update_captcha_menu_id).setVisible(true); return true; }
From source file:com.andybotting.tramhunter.activity.StopDetailsActivity.java
/** * Create the options for a given menu//from w w w . j av a 2 s . co m */ @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, MENU_ITEM_REFRESH, 0, "Refresh"); MenuItem menuItem1 = menu.findItem(MENU_ITEM_REFRESH); menuItem1.setIcon(R.drawable.ic_menu_refresh); menu.add(0, MENU_ITEM_FAVOURITE, 0, ""); // Title set in onMenuOpened() MenuItem menuItem2 = menu.findItem(MENU_ITEM_FAVOURITE); menuItem2.setIcon(R.drawable.ic_menu_star); menu.add(0, MENU_ITEM_MAP, 0, "Map"); MenuItem menuItem3 = menu.findItem(MENU_ITEM_MAP); menuItem3.setIcon(R.drawable.ic_menu_mapmode); return true; }
From source file:com.krayzk9s.imgurholo.ui.MessagingFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { ImgurHoloActivity activity = (ImgurHoloActivity) getActivity(); if (activity.getApiCall().settings.getString("theme", MainActivity.HOLO_LIGHT) .equals(MainActivity.HOLO_LIGHT)) inflater.inflate(R.menu.main, menu); else// ww w. j a v a2s .c o m inflater.inflate(R.menu.main_dark, menu); menu.findItem(R.id.action_refresh).setVisible(true); menu.findItem(R.id.action_upload).setVisible(false); if (messageData != null) { menu.findItem(R.id.action_report).setVisible(true); menu.findItem(R.id.action_reply).setVisible(true); menu.findItem(R.id.action_delete).setVisible(true); } else { menu.findItem(R.id.action_message).setVisible(true); } }
From source file:com.orbar.pxdemo.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // If the nav drawer is open, hide action items related to the content view boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerView); menu.findItem(R.id.action_search).setVisible(!drawerOpen); return super.onPrepareOptionsMenu(menu); }
From source file:com.example.igorklimov.popularmoviesdemo.fragments.DetailFragment.java
private void finishCreatingMenu(Menu menu) { MenuItem item = menu.findItem(R.id.action_share); if (!isTabletPreference(context)) { mActionProvider = new ShareActionProvider(getActivity()) { @Override/*from www .j av a 2s . c o m*/ public View onCreateActionView() { return null; } }; item.setIcon(R.drawable.ic_share); } else { mActionProvider = new ShareActionProvider(getActivity()); } MenuItemCompat.setActionProvider(item, mActionProvider); if (mTrailerUri != null) mActionProvider.setShareIntent(createShareIntent()); }
From source file:com.andrada.sitracker.ui.fragment.DirectoryChooserFragment.java
@Override public void onCreateOptionsMenu(@NotNull Menu menu, @NotNull MenuInflater inflater) { inflater.inflate(R.menu.directory_chooser, menu); final MenuItem menuItem = menu.findItem(R.id.new_folder_item); if (menuItem == null) { return;//from www . j a v a2s . co m } menuItem.setVisible(mInitialDirectory != null && isValidFile(new File(mInitialDirectory)) && mNewDirectoryName != null && mIsDirectoryChooser); }
From source file:net.olejon.mdapp.MedicationActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_medication, menu); mFavoriteMenuItem = menu.findItem(R.id.medication_menu_favorite); mAtcCodeMenuItem = menu.findItem(R.id.medication_menu_atc); getMedication();/*www .ja v a2s.c o m*/ return true; }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.editor.TaskDetailFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { menu.findItem(R.id.menu_share).setEnabled(!isLocked()); if (getActivity() instanceof MenuStateController) { final boolean visible = ((MenuStateController) getActivity()).childItemsVisible(); // Outside group to allow for action bar placement if (menu.findItem(R.id.menu_delete) != null) menu.findItem(R.id.menu_delete).setVisible(visible); if (menu.findItem(R.id.menu_revert) != null) menu.findItem(R.id.menu_revert).setVisible(visible); if (menu.findItem(R.id.menu_share) != null) menu.findItem(R.id.menu_share).setVisible(visible); }/*ww w. j a v a 2 s .c o m*/ }