List of usage examples for android.view MenuItem setEnabled
public MenuItem setEnabled(boolean enabled);
From source file:at.bitfire.davdroid.mirakel.syncadapter.LoginURLFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { boolean ok = editUserName.getText().length() > 0 && editPassword.getText().length() > 0; if (ok)//from www. java 2 s . com // check host name try { URI uri = new URI(URLUtils.sanitize(scheme + editBaseURI.getText().toString())); if (StringUtils.isBlank(uri.getHost())) ok = false; } catch (URISyntaxException e) { ok = false; } MenuItem item = menu.findItem(R.id.next); item.setEnabled(ok); }
From source file:at.bitfire.davdroid.syncadapter.LoginURLFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { boolean usernameOk = editUserName.getText().length() > 0, passwordOk = editPassword.getText().length() > 0, urlOk = false;//from ww w. j a va2s.c om // check host name try { if (!StringUtils.isBlank(getBaseURI().getHost())) urlOk = true; } catch (Exception e) { } MenuItem item = menu.findItem(R.id.next); item.setEnabled(usernameOk && passwordOk && urlOk); }
From source file:com.justplay1.shoppist.features.category.CategoriesActivity.java
@Override public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) { super.onPrepareActionMode(actionMode, menu); MenuItem delete = menu.findItem(R.id.menu_delete); delete.setVisible(fragment.isDeleteButtonEnable()); MenuItem checkAll = menu.findItem(R.id.menu_check_all); checkAll.setEnabled(fragment.isCheckAllButtonEnable()); return true;/*from w ww.j ava2 s .c o m*/ }
From source file:at.bitfire.davdroid.syncadapter.EnterCredentialsFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { boolean ok = editUserName.getText().length() > 0 && editPassword.getText().length() > 0; // check host name try {//w w w . j a v a 2 s . c o m URL url = new URL(URIUtils.sanitize(protocol + editBaseURL.getText().toString())); if (url.getHost() == null || url.getHost().isEmpty()) ok = false; } catch (MalformedURLException e) { ok = false; } MenuItem item = menu.findItem(R.id.next); item.setEnabled(ok); }
From source file:at.bitfire.davdroid.mirakel.syncadapter.EnterCredentialsFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { boolean ok = editUserName.getText().length() > 0 && editPassword.getText().length() > 0; if (ok) {/*from w w w . jav a 2 s. com*/ // check host name try { URI uri = new URI(URIUtils.sanitize(protocol + editBaseURL.getText().toString())); if (StringUtils.isBlank(uri.getHost())) ok = false; } catch (URISyntaxException e) { ok = false; } } MenuItem item = menu.findItem(R.id.next); item.setEnabled(ok); }
From source file:org.exfio.csyncdroid.syncadapter.ExfioPeerEnterCredentialsFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { boolean ok = editUserName.getText().length() > 0 && editPassword.getText().length() > 0; // check host name try {//from w w w . j a v a 2s.c o m URI uri = new URI(URIUtils.sanitize(protocol + editBaseURL.getText().toString())); if (StringUtils.isBlank(uri.getHost())) ok = false; } catch (URISyntaxException e) { ok = false; } MenuItem item = menu.findItem(R.id.next); item.setEnabled(ok); }
From source file:com.justplay1.shoppist.features.goods.GoodsActivity.java
@Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { super.onPrepareActionMode(mode, menu); MenuItem edit = menu.findItem(R.id.action_edit); if (edit != null) { edit.setVisible(fragment.isEditButtonEnable()); }/*from w w w . java 2 s. c om*/ MenuItem checkAll = menu.findItem(R.id.menu_check_all); checkAll.setEnabled(fragment.isCheckAllButtonEnable()); return true; }
From source file:com.bodeme.easycloud.syncadapter.EnterCredentialsFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { boolean ok = editUserName.getText().length() > 0 && editPassword.getText().length() > 0; // check host name if (Constants.OWNCLOUD_URL == null) { try {// www. ja va 2s. co m URI uri = new URI(URIUtils.sanitize(editURL.getText().toString())); if (StringUtils.isBlank(uri.getHost())) ok = false; } catch (URISyntaxException e) { ok = false; } } MenuItem item = menu.findItem(R.id.next); item.setEnabled(ok); }
From source file:com.tlongdev.bktf.util.Utility.java
public static PopupMenu createItemPopupMenu(final Activity activity, View anchor, final Item item) { PopupMenu menu = new PopupMenu(activity, anchor); menu.getMenuInflater().inflate(R.menu.popup_item, menu.getMenu()); menu.getMenu().findItem(R.id.favorite) .setTitle(isFavorite(activity, item) ? "Remove from favorites" : "Add to favorites"); menu.getMenu().findItem(R.id.calculator).setEnabled(!isInCalculator(activity, item)); menu.setOnMenuItemClickListener(new android.widget.PopupMenu.OnMenuItemClickListener() { @Override// w ww .j av a2s . com public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.history: Intent i = new Intent(activity, PriceHistoryActivity.class); i.putExtra(PriceHistoryActivity.EXTRA_ITEM, item); activity.startActivity(i); break; case R.id.favorite: if (isFavorite(activity, item)) { removeFromFavorites(activity, item); } else { addToFavorites(activity, item); } break; case R.id.calculator: addToCalculator(activity, item); menuItem.setEnabled(false); break; case R.id.backpack_tf: CustomTabActivityHelper.openCustomTab(activity, new CustomTabsIntent.Builder().build(), Uri.parse(item.getBackpackTfUrl()), new WebViewFallback()); break; case R.id.wiki: CustomTabActivityHelper.openCustomTab(activity, new CustomTabsIntent.Builder().build(), Uri.parse(item.getTf2WikiUrl()), new WebViewFallback()); break; } return true; } }); return menu; }
From source file:org.exfio.csyncdroid.syncadapter.FxAccountEnterCredentialsFragment.java
@Override public void onPrepareOptionsMenu(Menu menu) { boolean ok = editUserName.getText().length() > 0 && editPassword.getText().length() > 0; // check host name try {//from w ww .j a v a 2 s. c o m URI uri = new URI(URIUtils.sanitize(accountServerProtocol + editAccountServerUrl.getText().toString())); if (StringUtils.isBlank(uri.getHost())) ok = false; } catch (URISyntaxException e) { ok = false; } MenuItem item = menu.findItem(R.id.next); item.setEnabled(ok); }