List of usage examples for android.view MenuItem getActionView
public View getActionView();
From source file:com.albedinsky.android.ui.widget.ActionTextButton.java
/** * Obtains action view of an item with the specified <var>itemId</var> from the given <var>menu</var>. * * @param menu The menu where is the item presented. * @param itemId Id of the menu item of which action view to obtain. * @return Obtained view or {@code null} if the item does not have action view or it is not * presented within the given menu./* w w w . ja v a 2 s . c om*/ */ @SuppressLint("NewApi") private static View obtainActionView(Menu menu, int itemId) { final MenuItem menuItem = menu.findItem(itemId); if (menuItem == null) return null; return COMPAT_MODE ? MenuItemCompat.getActionView(menuItem) : menuItem.getActionView(); }
From source file:com.odoo.core.utils.OAppBarUtils.java
public static void bindShopMenu(final AppCompatActivity activity, int[] hideMenuIds, Menu menu) { final ShopCart shopCart = new ShopCart(activity); MenuItem cart = menu.findItem(R.id.menu_show_cart); for (int menuId : hideMenuIds) { Log.v("", "Hiding menu " + menu.findItem(menuId).getTitle()); menu.findItem(menuId).setVisible(false); }/*from w w w . ja va 2 s .c om*/ // menu.findItem(R.id.menu_search_product).setVisible(!isHome); // Binding cart and its badge final RelativeLayout cartBadge = (RelativeLayout) cart.getActionView(); int counter = shopCart.counter(); setCounter(counter, cartBadge); cart.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { OAppBarUtils.onShopMenuItemClick(activity, null, item); return true; } }); cartBadge.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { OFragmentUtils.get(activity, null).startFragment(new CartFragment(), true, null); } }); }
From source file:com.thelastcrusade.soundstream.SearchActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the options menu from XML getMenuInflater().inflate(R.menu.search_menu, menu); // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); MenuItem searchItem = menu.findItem(R.id.search); SearchView searchView = (SearchView) searchItem.getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(true); return true;/*from w w w .ja v a 2 s . c om*/ }
From source file:com.github.rutvijkumar.twittfuse.activities.BaseFragmentActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.tweets_menus, menu); MenuItem searchItem = menu.findItem(R.id.action_search); searchView = (SearchView) searchItem.getActionView(); Util.setupSearchView(this, searchView); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); composeActionMenu = menu.findItem(R.id.action_compose); composeActionVisibility(false);/*from w w w . j a v a2s .com*/ return true; }
From source file:igor70334.mymovies.ui.activity.BaseActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView;/*w w w . j av a2 s . c o m*/ MenuItem item = menu.findItem(R.id.search); searchView = (SearchView) item.getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setQueryHint(getResources().getString(R.string.search_hint)); return true; }
From source file:com.possebom.openwifipasswordrecover.fragment.NetworkFragment.java
@Override public final void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.main, menu); MenuItem searchItem = menu.findItem(R.id.action_search); mSearchView = (SearchView) searchItem.getActionView(); mSearchView.setOnQueryTextListener(this); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.conferenceengineer.android.iosched.ui.phone.SessionsActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override//ww w . j av a 2s. co m public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.search, menu); MenuItem searchItem = menu.findItem(R.id.menu_search); if (searchItem != null && UIUtils.hasHoneycomb()) { SearchView searchView = (SearchView) searchItem.getActionView(); if (searchView != null) { SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setQueryRefinementEnabled(true); } } return true; }
From source file:de.dknapps.pswgendroid.ServiceListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options_menu, menu); MenuItem searchMenuItem = menu.findItem(R.id.search); SearchView searchView = (SearchView) searchMenuItem.getActionView(); searchView.setOnQueryTextListener(serviceListFragment); return true;//ww w . j a va 2 s . c o m }
From source file:org.apache.cordova.navigationmenu.NavigationMenu.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void enableMenuItem(MenuItem menuItem, boolean enable) { View actionView = menuItem.getActionView(); if (actionView != null) { if (enable) { actionView.setAlpha(255);// w w w. j ava 2 s. co m } else { actionView.setAlpha(130); } } }
From source file:co.iyubinest.bonzai.photos.list.PhotoListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.photo_list_search_menu, menu); MenuItem searchMenuItem = menu.findItem(R.id.action_search); searchView = (SearchView) searchMenuItem.getActionView(); searchView.setOnQueryTextListener(listener); searchView.setOnQueryTextFocusChangeListener((v, hasFocus) -> { if (!hasFocus) { MenuItemCompat.collapseActionView(searchMenuItem); }/*from w ww .j a v a 2 s . c o m*/ }); MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { photosView.setVisibility(View.INVISIBLE); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { photosView.setVisibility(View.VISIBLE); return true; } }); return true; }