List of usage examples for android.view Menu findItem
public MenuItem findItem(int id);
From source file:com.adguard.android.contentblocker.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // If the nav drawer is open, hide action items related to the content view boolean drawerOpen = drawerLayout.isDrawerVisible(leftDrawer); menu.findItem(R.id.refresh).setVisible(!drawerOpen); return super.onPrepareOptionsMenu(menu); }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.ThreadViewFragment.java
/** * Checks the proper sort option in our options menu. * @param sort Code for the sort type.//from www. jav a2 s .c o m * @param menu The fragment's menu. */ private void setSortCheck(int sort, Menu menu) { MenuItem item; switch (sort) { case SortUtil.SORT_DATE_NEWEST: item = menu.findItem(R.id.comment_sort_date_new); item.setChecked(true); return; case SortUtil.SORT_DATE_OLDEST: item = menu.findItem(R.id.comment_sort_date_new); item.setChecked(true); return; case SortUtil.SORT_LOCATION: item = menu.findItem(R.id.comment_sort_location); item.setChecked(true); return; case SortUtil.SORT_USER_SCORE_HIGHEST: item = menu.findItem(R.id.comment_sort_score_high); item.setChecked(true); return; case SortUtil.SORT_USER_SCORE_LOWEST: item = menu.findItem(R.id.comment_sort_score_low); item.setChecked(true); return; case SortUtil.SORT_IMAGE: item = menu.findItem(R.id.comment_sort_image); item.setChecked(true); return; default: return; } }
From source file:ac.robinson.ticqr.TicQRActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu, menu); if (TextUtils.isEmpty(mEmailContents)) { // don't show the send button when there is no email to send menu.findItem(R.id.action_send_order).setVisible(false); }//from w ww . ja v a 2s .c o m if (mBitmap == null) { menu.findItem(R.id.action_rescan).setVisible(false); } return super.onCreateOptionsMenu(menu); }
From source file:cc.echonet.coolmicapp.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); if (isThreadOn) { menu.findItem(R.id.menu_action_settings).setVisible(false); } else {// w w w . j a v a 2 s .c o m menu.findItem(R.id.menu_action_settings).setVisible(true); } return true; }
From source file:ca.rmen.android.poetassistant.main.reader.ReaderFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); Log.d(TAG, "onCreateOptionsMenu() called with: " + "menu = [" + menu + "], inflater = [" + inflater + "]"); inflater.inflate(R.menu.menu_tts, menu); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { menu.findItem(R.id.action_new).setTitle(R.string.file_clear); menu.findItem(R.id.action_open).setVisible(false); menu.findItem(R.id.action_save).setVisible(false); menu.findItem(R.id.action_save_as).setVisible(false); }//from w ww . j av a 2s . c o m }
From source file:com.kiwiteam.nomiddleman.LargeGroupActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.global, menu); if (conn.isLogged()) { menu.findItem(R.id.account).setVisible(true); menu.findItem(R.id.signout).setVisible(true); } else {/*from ww w .j av a2 s . co m*/ menu.findItem(R.id.account).setVisible(false); menu.findItem(R.id.signout).setVisible(false); } //initSearchView(menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName()); searchView.setSearchableInfo(searchableInfo); return true; }
From source file:com.zotfeed2.CardContentFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_anteater_tv, menu); // MenuItem item = menu.findItem(R.id.action_search); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); MenuItem searchItem = menu.findItem(R.id.action_search); SearchView sv = (SearchView) MenuItemCompat.getActionView(searchItem); if (sv != null) { sv.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override/*from ww w. j av a2 s . co m*/ public boolean onQueryTextSubmit(String query) { System.out.print("QUERY:" + query); ArrayList<VideoItem> results = new ArrayList<VideoItem>(); if (!videoBeans.isEmpty() || videoBeans != null) { for (VideoItem videoItem : videoBeans) { //System.out.println("Title: " + article.getTitle()); if (videoItem.getTitle().toLowerCase().contains(query.toLowerCase())) { results.add(videoItem); } } System.out.println("Size: " + results.size()); search = true; recyclerView.setAdapter(new ContentAdapter(results)); recyclerView.setHasFixedSize(true); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); return true; } else { return false; } } @Override public boolean onQueryTextChange(String newText) { if (newText.isEmpty() || newText.equals(" ")) { if (videoBeans != null) { recyclerView.setAdapter(new ContentAdapter(videoBeans)); recyclerView.setHasFixedSize(true); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); } } return false; } }); } super.onCreateOptionsMenu(menu, inflater); }
From source file:azad.hallaji.farzad.com.masirezendegi.ExplainMoshaver.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_explain_moshaver); Fabric.with(this, new Crashlytics()); alagestarmoshaver = (ImageView) findViewById(R.id.alagestarmoshaver); if (savedInstanceState == null) { Bundle extras = getIntent().getExtras(); if (extras == null) { placeid = ""; } else {//from w w w .j a v a2 s . c om placeid = extras.getString("placeid"); } } else { placeid = (String) savedInstanceState.getSerializable("placeid"); } ImageView imageView1 = (ImageView) findViewById(R.id.backButton); imageView1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(ExplainMoshaver.this, PageMoshaverin.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); } }); final DrawerLayout 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); } userimg = (ImageView) findViewById(R.id.adviser_image); name_moshaver_textview = (TextView) findViewById(R.id.name_moshaver_textview); //taxassose_moshaver_textview =(TextView) findViewById(R.id.taxassose_moshaver_textview); code_moshaver_textview = (TextView) findViewById(R.id.code_moshaver_textview); if (savedInstanceState == null) { Bundle extras = getIntent().getExtras(); if (extras == null) { adviseridm = "0"; } else { adviseridm = extras.getString("adviserid"); } } else { adviseridm = (String) savedInstanceState.getSerializable("adviserid"); } //Toast.makeText(getApplicationContext(), "+"+adviseridm+"+", Toast.LENGTH_LONG).show(); if (isOnline()) { //requestData(); postgetData(); //Log.i("Lieseesene",License); ImageView imageView2 = (ImageView) findViewById(R.id.adviser_about_img); imageView2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //requestDataa(); if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) { Intent intent3 = new Intent(ExplainMoshaver.this, PageRezerv.class); intent3.putExtra("adviseridm", adviseridm); intent3.putExtra("placeid", placeid); intent3.putExtra("namemoshaver", namemoshaver); startActivity(intent3); } else { Toast.makeText(getApplicationContext(), " ", Toast.LENGTH_LONG).show(); } } }); // // final ImageView alagestarmarkaz = (ImageView)findViewById(R.id.alagestarmarkaz); alagestarmoshaver.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Log.i("sxascsdcpsdcpsdcpsdc","[sxascsdcpsdcpsdcpsdc"+alagestarmarkaz.getResources()); if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) { setAlage(); //Log.i("sxascsdcpsdcpsdcpsdc","[sxascsdcp2sdcpsdcpsdc"+hanyayo); } else { Toast.makeText(getApplicationContext(), " ", Toast.LENGTH_LONG).show(); } } }); ImageView adviser_reserve_img = (ImageView) findViewById(R.id.adviser_reserve_img); adviser_reserve_img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final LinearLayout darbareyehuseyin = (LinearLayout) findViewById(R.id.darbareyehuseyin); darbareyehuseyin.setVisibility(View.VISIBLE); TextView textTagsHusseyin = (TextView) findViewById(R.id.textTagsHusseyin); try { textTagsHusseyin.setText(Tagggggggs); ImageView closeafzundanejavab = (ImageView) findViewById(R.id.closeinvisibleimag); closeafzundanejavab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { darbareyehuseyin.setVisibility(View.GONE); } }); } catch (Exception e) { textTagsHusseyin.setText(""); } } }); } else { Toast.makeText(getApplicationContext(), "Network isn't available", Toast.LENGTH_LONG).show(); } }
From source file:cc.softwarefactory.lokki.android.activities.MainActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear();/*from w ww .j a v a 2s. co m*/ if (mNavigationDrawerFragment != null && !mNavigationDrawerFragment.isDrawerOpen()) { if (selectedOption == 0) { // Map getMenuInflater().inflate(R.menu.map, menu); MenuItem menuItem = menu.findItem(R.id.action_visibility); if (menuItem != null) { Log.e(TAG, "onPrepareOptionsMenu - Visible: " + MainApplication.visible); if (MainApplication.visible) { menuItem.setIcon(R.drawable.ic_visible); } else { menuItem.setIcon(R.drawable.ic_invisible); } } } else if (selectedOption == 2) { // Contacts screen getMenuInflater().inflate(R.menu.contacts, menu); } else if (selectedOption == -10) { // Add contacts screen getMenuInflater().inflate(R.menu.add_contact, menu); } getMenuInflater().inflate(R.menu.main_activity_actions, menu); menu.findItem(R.id.action_logout).setVisible(true); } return super.onPrepareOptionsMenu(menu); }
From source file:com.android.deskclock.worldclock.CitiesActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.cities_menu, menu); MenuItem help = menu.findItem(R.id.menu_item_help); if (help != null) { Utils.prepareHelpMenuItem(this, help); }/*from ww w . j a va2 s. c o m*/ MenuItem searchMenu = menu.findItem(R.id.menu_item_search); mSearchView = (SearchView) MenuItemCompat.getActionView(searchMenu); if (mSearchView != null) { /// M: Use the cities_menu.xml config,show the search button on keyboard @{ mSearchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI | mSearchView.getImeOptions()); /// @} mSearchView.setOnSearchClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mSearchMode = true; } }); mSearchView.setOnCloseListener(new SearchView.OnCloseListener() { @Override public boolean onClose() { mSearchMode = false; return false; } }); mSearchView.setOnQueryTextListener(this); mSearchView.setQuery(mQueryTextBuffer.toString(), false); if (mSearchMode) { mSearchView.requestFocus(); mSearchView.setIconified(false); } } return super.onCreateOptionsMenu(menu); }