Java Code Examples for android.support.v7.widget.SearchView#setSubmitButtonEnabled()
The following examples show how to use
android.support.v7.widget.SearchView#setSubmitButtonEnabled() .
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: SearchMusicActivity.java From YCAudioPlayer with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_search_music, menu); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setMaxWidth(Integer.MAX_VALUE); searchView.onActionViewExpanded(); searchView.setQueryHint(getString(R.string.search_tips)); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { searchMusic(query); return false; } @Override public boolean onQueryTextChange(String newText) { return false; } }); searchView.setSubmitButtonEnabled(true); try { Field field = searchView.getClass().getDeclaredField("mGoButton"); field.setAccessible(true); ImageView mGoButton = (ImageView) field.get(searchView); mGoButton.setImageResource(R.drawable.ic_menu_search); } catch (Exception e) { e.printStackTrace(); } return super.onCreateOptionsMenu(menu); }
Example 2
Source File: SearchActivity.java From Hands-Chopping with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.search_toobar,menu); MenuItem searchItem = menu.findItem(R.id.menu_search); //通过MenuItem得到SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); searchView.setSubmitButtonEnabled(true); searchView.setQueryHint("搜索游戏"); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { mPresenter.searchFromSteam(query); searchView.clearFocus(); // InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // if (imm != null) { // imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0); // } return true; } @Override public boolean onQueryTextChange(String newText) { return false; } }); return super.onCreateOptionsMenu(menu); }
Example 3
Source File: ElectionChoiceActivity.java From polling-station-app with GNU Lesser General Public License v3.0 | 5 votes |
/** * Handles the tasks that need to be performed when the menu is created. * Sets the custom menu layout and sets up the search field handlers. * @param menu * @return */ @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.choice_menu, menu); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); searchItem = menu.findItem(R.id.search); searchView = (SearchView) searchItem.getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); searchView.setSubmitButtonEnabled(true); searchView.setOnQueryTextListener(this); return true; }
Example 4
Source File: FriendSearchActivity.java From CoolChat with Apache License 2.0 | 5 votes |
private void initViews() { layout_points = (LinearLayout) findViewById(R.id.layout_points); SearchView searchView = (SearchView) findViewById(R.id.search_view); //设置显示提交按钮 searchView.setSubmitButtonEnabled(true); //一开始就处于显示SearchView的状态 searchView.setIconifiedByDefault(false); //设置一开始就显示输入框 searchView.setIconified(true); searchView.clearFocus(); SearchView.SearchAutoComplete editText = (SearchView.SearchAutoComplete) searchView.findViewById(R.id.search_src_text); editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { searchFriend(query.trim()); return false; } @Override public boolean onQueryTextChange(String newText) { if (!newText.isEmpty()) { searchFriend(newText); } return false; } }); }
Example 5
Source File: LocationPickerActivity.java From android with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_location_picker, menu); MenuItem searchItem = menu.findItem(R.id.search); if (searchItem != null) { SearchView sv = (SearchView) searchItem.getActionView(); sv.setSubmitButtonEnabled(false); sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return true; } @Override public boolean onQueryTextChange(String newText) { if (TextUtils.isEmpty(newText)) { mPresenter.filter(null); } else { mPresenter.filter(newText); } return true; } }); } return true; }
Example 6
Source File: FavouriteWorkflowsFragment.java From incubator-taverna-mobile with Apache License 2.0 | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context .SEARCH_SERVICE); searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity() .getComponentName())); searchView.setSubmitButtonEnabled(false); mFavouriteWorkflowsPresenter.attachSearchHandler(searchView); }
Example 7
Source File: SearchBook.java From iSCAU-Android with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(android.view.Menu menu) { getMenuInflater().inflate(R.menu.menu_searchbook, menu); menuItemSearch = menu.findItem(R.id.search_button); searchView = (SearchView) MenuItemCompat.getActionView(menuItemSearch); searchView.setQueryHint(getString(R.string.hint_searchbook)); searchView.setSubmitButtonEnabled(true); searchView.setOnQueryTextListener(oQueryTextListener); ImageView mSearchHintIcon = (ImageView) searchView.findViewById(R.id.search_mag_icon); mSearchHintIcon.setVisibility(View.GONE); MenuItemCompat.expandActionView(menuItemSearch); return true; }
Example 8
Source File: CatalogFragment.java From Ouroboros with GNU General Public License v3.0 | 4 votes |
@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); 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; } }); }
Example 9
Source File: ThreadFragment.java From Ouroboros with GNU General Public License v3.0 | 4 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem goToBottomButton = menu.findItem(R.id.action_scroll_bottom); MenuItem goToTopButton = menu.findItem(R.id.action_scroll_top); MenuItem replyButton = menu.findItem(R.id.action_reply); MenuItem watchlistButton = menu.findItem(R.id.action_add_watchlist); MenuItem refreshButton = menu.findItem(R.id.action_refresh); MenuItem galleryButton = menu.findItem(R.id.action_gallery); MenuItem saveAllImagesButton = menu.findItem(R.id.action_save_all_images); MenuItem openExternalButton = menu.findItem(R.id.action_external_browser); MenuItem shareButton = menu.findItem(R.id.menu_item_share); MenuItem menuLayout = menu.findItem(R.id.action_menu_layout); MenuItem searchButton = menu.findItem(R.id.action_search); searchButton.setVisible(true); final 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) { threadAdapter.setFilterQueryProvider(new FilterQueryProvider() { @Override public Cursor runQuery(CharSequence constraint) { return infiniteDbHelper.searchThreadForString(constraint.toString(), resto); } }); threadAdapter.getFilter().filter(newText); return true; } }); MenuItemCompat.setOnActionExpandListener(searchButton, this); refreshButton.setVisible(true); goToBottomButton.setVisible(true); goToTopButton.setVisible(true); replyButton.setVisible(true); galleryButton.setVisible(true); saveAllImagesButton.setVisible(true); openExternalButton.setVisible(true); shareButton.setVisible(true); watchlistButton.setVisible(true); menuLayout.setVisible(true); super.onCreateOptionsMenu(menu, inflater); }
Example 10
Source File: AtUserFragment.java From iBeebo with GNU General Public License v3.0 | 4 votes |
private void showSearchMenu(Menu menu) { SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); // searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH); searchView.setIconifiedByDefault(false); searchView.setSubmitButtonEnabled(false); searchView.setMaxWidth(Utility.dip2px(200)); // searchView.setQueryHint(getString(R.string.at_other)); // searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); // searchView.setIconifiedByDefault(false); // searchView.setQueryHint(getString(R.string.at_other)); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { if (!TextUtils.isEmpty(newText)) { if (task != null) { task.cancel(true); } task = new AtUserTask(newText); task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR); } else { if (task != null) { task.cancel(true); } atList.clear(); result.clear(); atList = AtUsersDBTask.get(BeeboApplication.getInstance().getCurrentAccountId()); for (AtUserBean b : atList) { result.add(b.getNickname()); } adapter.notifyDataSetChanged(); } return false; } }); searchView.requestFocus(); }
Example 11
Source File: AtUserFragment.java From iBeebo with GNU General Public License v3.0 | 4 votes |
private void showSearchMenu(Menu menu) { SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); // searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH); searchView.setIconifiedByDefault(false); searchView.setSubmitButtonEnabled(false); searchView.setMaxWidth(Utility.dip2px(200)); // searchView.setQueryHint(getString(R.string.at_other)); // searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName())); // searchView.setIconifiedByDefault(false); // searchView.setQueryHint(getString(R.string.at_other)); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { if (!TextUtils.isEmpty(newText)) { if (task != null) { task.cancel(true); } task = new AtUserTask(newText); task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR); } else { if (task != null) { task.cancel(true); } atList.clear(); result.clear(); atList = AtUsersDBTask.get(BeeboApplication.getInstance().getCurrentAccountId()); for (AtUserBean b : atList) { result.add(b.getNickname()); } adapter.notifyDataSetChanged(); } return false; } }); searchView.requestFocus(); }