Java Code Examples for androidx.core.view.MenuItemCompat#getActionView()
The following examples show how to use
androidx.core.view.MenuItemCompat#getActionView() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HadithFragment.java From prayer-times-android with Apache License 2.0 | 6 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MaterialMenuInflater.with(getActivity(), inflater) .setDefaultColorResource(R.color.white) .inflate(R.menu.hadis, menu); mSwitch = menu.findItem(R.id.favswitch); mFav = menu.findItem(R.id.fav); setCurrentPage(mPager.getCurrentItem()); MenuItem item = menu.findItem(R.id.menu_item_share); item.setOnMenuItemClickListener(item1 -> { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, mShareText); sendIntent.setType("text/plain"); startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.share))); return true; }); item = menu.findItem(R.id.menu_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(item); searchView.setOnQueryTextListener(this); }
Example 2
Source File: BoxBrowseActivity.java From box-android-browse-sdk with Apache License 2.0 | 6 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.box_browsesdk_fragment_container); mSearchViewMenuItem = menu.findItem(R.id.box_browsesdk_action_search); mSearchView = (BoxSearchView) MenuItemCompat.getActionView(mSearchViewMenuItem); if (fragment instanceof BoxSearchFragment) { mSearchView.setIconified(false); mSearchView.setSearchTerm(((BoxSearchFragment)fragment).getSearchQuery()); } enableDisableRecentView(); mSearchView.setOnBoxSearchListener(this); return true; }
Example 3
Source File: SubsonicFragment.java From Audinaut with GNU General Public License v3.0 | 6 votes |
void onFinishSetupOptionsMenu(final Menu menu) { searchItem = menu.findItem(R.id.menu_global_search); if (searchItem != null) { searchView = (SearchView) MenuItemCompat.getActionView(searchItem); SearchManager searchManager = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE); SearchableInfo searchableInfo = searchManager.getSearchableInfo(context.getComponentName()); if (searchableInfo == null) { Log.w(TAG, "Failed to get SearchableInfo"); } else { searchView.setSearchableInfo(searchableInfo); } String currentQuery = getCurrentQuery(); if (currentQuery != null) { searchView.setOnSearchClickListener(v -> searchView.setQuery(getCurrentQuery(), false)); } } }
Example 4
Source File: ContactSelectionActivity.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.group_create_menu, menu); menu.removeItem(R.id.Next); if (disableCheckBox) { menu.removeItem(R.id.Done); } MenuItem searchItem = menu.findItem(R.id.menu_search); searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setQueryHint(getResources().getString(R.string.search_hint)); if (Utils.hasICS()) { searchItem.collapseActionView(); } searchView.setOnQueryTextListener(this); searchView.setIconified(true); return super.onCreateOptionsMenu(menu); }
Example 5
Source File: HadithFragment.java From prayer-times-android with Apache License 2.0 | 6 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MaterialMenuInflater.with(getActivity(), inflater) .setDefaultColorResource(R.color.white) .inflate(R.menu.hadis, menu); mSwitch = menu.findItem(R.id.favswitch); mFav = menu.findItem(R.id.fav); setCurrentPage(mPager.getCurrentItem()); MenuItem item = menu.findItem(R.id.menu_item_share); item.setOnMenuItemClickListener(item1 -> { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, mShareText); sendIntent.setType("text/plain"); startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.share))); return true; }); item = menu.findItem(R.id.menu_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(item); searchView.setOnQueryTextListener(this); }
Example 6
Source File: OverviewFragment.java From kolabnotes-android with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu,inflater); inflater.inflate(R.menu.main_toolbar, menu); // Create the search view mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id .action_search)); setUpSearchView(mSearchView); }
Example 7
Source File: SmsDragListActivity.java From financisto with GNU General Public License v2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.draglist_menu, menu); final MenuItem searchItem = menu.findItem(R.id.action_search); final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } /** * Not sense doing via android.widget.Filter as adapter and its data is filtered in async mode */ @Override public boolean onQueryTextChange(String newText) { cursorSource.setConstraint(newText); adapter.reloadAsyncSource(); if (!StringUtil.isEmpty(newText)) { Log.i(TAG, "filtered by `" + newText + "`"); // Toast.makeText(SmsDragListActivity.this, "filtered by '" + newText + "'", Toast.LENGTH_SHORT).show(); } return true; } }); final MenuItem newItem = menu.findItem(R.id.new_sms_template); newItem.setOnMenuItemClickListener(this::addItem); return true; }
Example 8
Source File: BoxBrowseActivity.java From box-android-browse-sdk with Apache License 2.0 | 5 votes |
private void clearSearch() { if (mSearchViewMenuItem == null) { return; } BoxSearchView searchView = (BoxSearchView) MenuItemCompat.getActionView(mSearchViewMenuItem); if (!searchView.isIconified()) { searchView.onActionViewCollapsed(); searchView.setIconified(true); } }
Example 9
Source File: BoxBrowseActivity.java From box-android-browse-sdk with Apache License 2.0 | 5 votes |
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (mSearchViewMenuItem == null) { return; } BoxSearchView searchView = (BoxSearchView) MenuItemCompat.getActionView(mSearchViewMenuItem); outState.putBoolean(RESTORE_SEARCH, !searchView.isIconified()); outState.putString(SEARCH_QUERY, searchView.getQuery().toString()); }
Example 10
Source File: MobiComKitPeopleActivity.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 5 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_contact, menu); MenuItem searchItem = menu.findItem(R.id.menu_search); searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setQueryHint(getResources().getString(R.string.search_hint)); if (Utils.hasICS()) { searchItem.collapseActionView(); } searchView.setOnQueryTextListener(this); searchView.setSubmitButtonEnabled(true); searchView.setIconified(true); return super.onCreateOptionsMenu(menu); }
Example 11
Source File: ActionBarSearchActivity.java From android-test with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { inflater.inflate(R.menu.actionbar_search_actions, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); MenuItem searchItem = menu.findItem(R.id.menu_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); return super.onCreateOptionsMenu(menu); }
Example 12
Source File: SearchCityFragment.java From prayer-times-android with Apache License 2.0 | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MaterialMenuInflater.with(getActivity(), inflater) .setDefaultColorResource(R.color.white) .inflate(R.menu.search, menu); mSearchItem = menu.findItem(R.id.menu_search); SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem); mSearchView.performClick(); mSearchView.setOnQueryTextListener(this); }
Example 13
Source File: NamesFragment.java From prayer-times-android with Apache License 2.0 | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MaterialMenuInflater.with(getActivity(), inflater) .setDefaultColorResource(R.color.white) .inflate(R.menu.search, menu); MenuItem item = menu.findItem(R.id.menu_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(item); searchView.setOnQueryTextListener(this); }
Example 14
Source File: DhikrFragment.java From prayer-times-android with Apache License 2.0 | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MaterialMenuInflater.with(getActivity(), inflater).setDefaultColorResource(R.color.white).inflate(R.menu.zikr, menu); MenuItem item = menu.findItem(R.id.menu_spinner); mSpinner = (Spinner) MenuItemCompat.getActionView(item); onChanged(mViewModel.getDhikrs().getValue()); }
Example 15
Source File: SongsListFragment.java From Kore with Apache License 2.0 | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { if (!isAdded()) { // HACK: Fix crash reported on Play Store. Why does this is necessary is beyond me super.onCreateOptionsMenu(menu, inflater); return; } inflater.inflate(R.menu.media_search, menu); MenuItem searchItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setOnQueryTextListener(this); searchView.setQueryHint(getString(R.string.action_search_albums)); super.onCreateOptionsMenu(menu, inflater); }
Example 16
Source File: SearchCityFragment.java From prayer-times-android with Apache License 2.0 | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MaterialMenuInflater.with(getActivity(), inflater) .setDefaultColorResource(R.color.white) .inflate(R.menu.search, menu); mSearchItem = menu.findItem(R.id.menu_search); SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem); mSearchView.performClick(); mSearchView.setOnQueryTextListener(this); }
Example 17
Source File: NamesFragment.java From prayer-times-android with Apache License 2.0 | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); MaterialMenuInflater.with(getActivity(), inflater) .setDefaultColorResource(R.color.white) .inflate(R.menu.search, menu); MenuItem item = menu.findItem(R.id.menu_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(item); searchView.setOnQueryTextListener(this); }
Example 18
Source File: SelectFileActivity.java From turbo-editor with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_select_file, menu); mSearchViewMenuItem = menu.findItem(R.id.im_search); mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchViewMenuItem); mSearchView.setIconifiedByDefault(true); mSearchView.setOnQueryTextListener(this); mSearchView.setSubmitButtonEnabled(false); return super.onCreateOptionsMenu(menu); }
Example 19
Source File: MainActivity.java From Status with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); resetItem = menu.findItem(R.id.action_reset); searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search)); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { adapter.filter(viewPager.getCurrentItem(), query.toLowerCase()); appbar.setExpanded(true); return true; } @Override public boolean onQueryTextChange(String newText) { adapter.filter(viewPager.getCurrentItem(), newText.toLowerCase()); appbar.setExpanded(true); return true; } }); searchView.setOnCloseListener(() -> { adapter.filter(viewPager.getCurrentItem(), null); return false; }); return super.onCreateOptionsMenu(menu); }
Example 20
Source File: MainActivity.java From MusicBobber with MIT License | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.clear(); getMenuInflater().inflate(R.menu.main, menu); MenuItem searchItem = menu.findItem(R.id.item_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setOnQueryTextListener(this); return true; }