List of usage examples for android.view MenuItem getActionView
public View getActionView();
From source file:com.github.riotopsys.malforandroid2.activity.HubActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.base, menu); searchItem = menu.findItem(R.id.menu_search); searchView = (SearchView) searchItem.getActionView(); searchView.setOnQueryTextListener(this); searchView.setQueryHint(getString(R.string.search)); MenuItem refreshItem = menu.findItem(R.id.refresh_menu_item); refreshView = (RefreshProgressActionView) refreshItem.getActionView(); refreshView.setOnClickListener(this); refreshView.setBusy(state.isBusy()); return super.onCreateOptionsMenu(menu); }
From source file:koma.movieapp.ui.SearchActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.search, menu); final MenuItem searchItem = menu.findItem(R.id.menu_search); if (searchItem != null) { SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchView view = (SearchView) searchItem.getActionView(); mSearchView = view;/*from ww w. j a v a 2 s .c o m*/ if (view == null) { LOGW(TAG, "Could not set up search view, view is null."); } else { view.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); view.setIconified(false); view.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String s) { view.clearFocus(); Bundle args = new Bundle(); args.putString("title", "Search"); args.putInt("queryType", Config.SEARCH_TOKEN); args.putString("searchString", s); mMoviesFragment.reloadFromArguments(args); return true; } @Override public boolean onQueryTextChange(String s) { // if (null != mMoviesFragment) { // mMoviesFragment.requestQueryUpdate(s); // } return true; } }); view.setOnCloseListener(new SearchView.OnCloseListener() { @Override public boolean onClose() { finish(); return false; } }); } if (!TextUtils.isEmpty(mQuery)) { view.setQuery(mQuery, false); } } return true; }
From source file:com.google.samples.apps.sergio.ui.SearchActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.search, menu); final MenuItem searchItem = menu.findItem(R.id.menu_search); if (searchItem != null) { SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchView view = (SearchView) searchItem.getActionView(); mSearchView = view;//from w w w. j a v a 2 s . c o m if (view == null) { LOGW(TAG, "Could not set up search view, view is null."); } else { view.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); view.setIconified(false); view.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String s) { view.clearFocus(); if ("zzznotif".equals(s)) { (new ShowFeedbackNotificationAction()).run(SearchActivity.this, null); } return true; } @Override public boolean onQueryTextChange(String s) { if (null != mSessionsFragment) { mSessionsFragment.requestQueryUpdate(s); } return true; } }); view.setOnCloseListener(new SearchView.OnCloseListener() { @Override public boolean onClose() { finish(); return false; } }); } if (!TextUtils.isEmpty(mQuery)) { view.setQuery(mQuery, false); } } return true; }
From source file:com.luorrak.ouroboros.catalog.CatalogFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_catalog, menu); MenuItem replyButton = menu.findItem(R.id.action_reply); MenuItem openExternalButton = menu.findItem(R.id.action_external_browser); MenuItem menuLayout = menu.findItem(R.id.action_menu_layout); MenuItem shareButton = menu.findItem(R.id.menu_item_share); MenuItem sortBy = menu.findItem(R.id.action_sort_by); replyButton.setVisible(true);/*w w w.ja va 2s. c o m*/ openExternalButton.setVisible(true); menuLayout.setVisible(true); sortBy.setVisible(true); shareButton.setVisible(true); shareActionProvider = MenuItemCompat.getActionProvider(shareButton); MenuItem searchButton = menu.findItem(R.id.action_search); searchButton.setVisible(true); SearchView searchView = (SearchView) searchButton.getActionView(); searchView.setIconifiedByDefault(false); searchView.setSubmitButtonEnabled(false); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { Log.d(LOG_TAG, "query=" + newText); catalogAdapter.setFilterQueryProvider(new FilterQueryProvider() { @Override public Cursor runQuery(CharSequence constraint) { return infiniteDbHelper.searchCatalogForThread(constraint.toString(), SettingsHelper.getSortByMethod(getContext())); } }); catalogAdapter.getFilter().filter(newText); return true; } }); }
From source file:com.klinker.android.theme_spotlight.activity.SpotlightActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_searchable, menu); MenuItem search = menu.findItem(R.id.search); mSearchView = (SearchView) search.getActionView(); mSearchView.setOnQueryTextListener(this); hackSearchView();/*from w w w.j a va 2 s . co m*/ return true; }
From source file:com.scrachx.foodfacts.checker.ui.main.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.main, menu); // Associate searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); MenuItem searchMenuItem = menu.findItem(R.id.action_search); mSearchView = (SearchView) searchMenuItem.getActionView(); mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() { @Override//from w w w. j av a2 s.c o m public boolean onMenuItemActionExpand(MenuItem item) { return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container); // Not replace if no search has been done (no switch of fragment) if (currentFragment instanceof SearchFragment) { getSupportFragmentManager().beginTransaction() .replace(R.id.fragment_container, SearchFragment.newInstance(), SearchFragment.TAG) .commit(); } return true; } }); return true; }
From source file:it_minds.dk.eindberetningmobil_android.views.StartActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.startactivity_menu, menu); final MenuItem badgeItem = menu.findItem(R.id.missing_trip_menu_counter); final RelativeLayout badgeLayout = (RelativeLayout) badgeItem.getActionView(); //Set badge//from w ww . j a v a 2 s. com if (badgeCount > 0) { badgeItem.setVisible(true); TextView tv = (TextView) badgeLayout.findViewById(R.id.actionbar_notifcation_textview); tv.setText(badgeCount + ""); } else { badgeItem.setVisible(false); } return true; }
From source file:jm.org.data.area.IndicatorActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem searchViewMenuItem = menu.findItem(R.id.menu_search); SearchView mSearchView = (SearchView) searchViewMenuItem.getActionView(); int searchImgId = getResources().getIdentifier("android:id/search_button", null, null); ImageView v = (ImageView) mSearchView.findViewById(searchImgId); v.setImageResource(R.drawable.ic_action_search); return super.onPrepareOptionsMenu(menu); }
From source file:com.github.jvanhie.discogsscrobbler.ReleaseListActivity.java
@Override public boolean onCreateOptionsMenu(final Menu menu) { if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("enable_discogs", true)) { // Inflate the menu; this adds items to the action bar if it is present. MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.discogs_list, menu); //configure search box final MenuItem search = menu.findItem(R.id.list_search); SearchView searchView = (SearchView) search.getActionView(); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override//from w w w.j av a2s. c o m public boolean onQueryTextSubmit(String s) { menu.findItem(R.id.list_search).collapseActionView(); return false; } @Override public boolean onQueryTextChange(String s) { mReleaseList.filter(s); return false; } }); searchView.setQueryHint("Filter your releases"); final MenuItem filter = menu.findItem(R.id.list_filter); if (!mFolders) { mDiscogs.getFolders(new Discogs.DiscogsDataWaiter<List<Folder>>() { @Override public void onResult(boolean success, List<Folder> data) { if (success && data != null) { mFolders = true; Spinner s = (Spinner) filter.getActionView(); // find the spinner ArrayAdapter<Folder> mSpinnerAdapter = new ArrayAdapter<Folder>( getSupportActionBar().getThemedContext(), android.R.layout.simple_spinner_dropdown_item, data); mSpinnerAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item); s.setAdapter(mSpinnerAdapter); // set the adapter s.setSelection(0, false); s.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { mDiscogs.setFolderId(((Folder) adapterView.getItemAtPosition(i)).folderid); //reload list with id mReleaseList.loadList(); filter.collapseActionView(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { //filter.collapseActionView(); } }); } } }); } //make sure only one actionview is expanded MenuItemCompat.setOnActionExpandListener(filter, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem menuItem) { //collapse search search.collapseActionView(); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem menuItem) { return true; } }); MenuItemCompat.setOnActionExpandListener(search, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem menuItem) { //collapse search filter.collapseActionView(); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem menuItem) { return true; } }); //s.setSelection(mSearchType,false); if (mSelected > 0) { if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("enable_lastfm", true)) { inflater.inflate(R.menu.release_detail_scrobble, menu); } } } return true; }
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.HomeActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/*from w ww. java 2s . co m*/ public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); mOptionsMenu = menu; getMenuInflater().inflate(R.menu.home, 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; }