Java Code Examples for androidx.appcompat.widget.SearchView#setQueryHint()
The following examples show how to use
androidx.appcompat.widget.SearchView#setQueryHint() .
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: FavoriteFragment.java From materialistic with Apache License 2.0 | 6 votes |
private void createSearchView(MenuItem menuSearch) { final SearchView searchView = (SearchView) mActionViewResolver.getActionView(menuSearch); searchView.setQueryHint(getString(R.string.hint_search_saved_stories)); searchView.setSearchableInfo(((SearchManager) getActivity() .getSystemService(Context.SEARCH_SERVICE)) .getSearchableInfo(getActivity().getComponentName())); searchView.setIconified(!mSearchViewExpanded); searchView.setQuery(mFilter, false); searchView.setOnSearchClickListener(v -> { mSearchViewExpanded = true; v.requestFocus(); }); searchView.setOnCloseListener(() -> { // trigger a dummy empty search intent, as empty query does not get submitted searchView.setQuery(FavoriteActivity.EMPTY_QUERY, true); return false; }); }
Example 2
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 3
Source File: ConversationActivity.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 6 votes |
@SuppressLint("NewApi") @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. showActionBar(); //return false; getMenuInflater().inflate(R.menu.mobicom_basic_menu_for_normal_message, 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.setIconifiedByDefault(true); if (quickConversationFragment != null && !TextUtils.isEmpty(quickConversationFragment.getSearchString())) { searchView.setIconified(false); searchView.setQuery(quickConversationFragment.getSearchString(), false); } return super.onCreateOptionsMenu(menu); }
Example 4
Source File: OverviewFragment.java From kolabnotes-android with GNU Lesser General Public License v3.0 | 6 votes |
/** * Set up the search view with OnQueryTextListener() * * @param searchView the search view which need to be set up */ private void setUpSearchView(final SearchView searchView) { searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { searchNotes(query); // Submit the search will hide the keyboard searchView.clearFocus(); return true; } @Override public boolean onQueryTextChange(String newText) { // Apply the filter when the text is changing searchNotes(newText); return true; } }); searchView.setQueryHint(getString(R.string.dialog_input_text_search_hint)); }
Example 5
Source File: FragmentContacts.java From FairEmail with GNU General Public License v3.0 | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_contacts, menu); MenuItem menuSearch = menu.findItem(R.id.menu_search); SearchView searchView = (SearchView) menuSearch.getActionView(); searchView.setQueryHint(getString(R.string.title_search)); if (!TextUtils.isEmpty(searching)) { menuSearch.expandActionView(); searchView.setQuery(searching, true); } searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { searching = newText; adapter.search(newText); return true; } @Override public boolean onQueryTextSubmit(String query) { searching = query; adapter.search(query); return true; } }); super.onCreateOptionsMenu(menu, inflater); }
Example 6
Source File: NetFragment.java From pandora with Apache License 2.0 | 5 votes |
private void setSearchView() { MenuItem menuItem = getToolbar().getMenu().findItem(R.id.pd_menu_id_2); SearchView searchView = (SearchView) menuItem.getActionView(); searchView.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); searchView.setQueryHint(ViewKnife.getString(R.string.pd_net_search_hint)); searchView.setOnQueryTextListener(new SimpleOnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { filter(newText); return true; } @Override public boolean onQueryTextSubmit(String query) { closeSoftInput(); filter(query); return true; } }); SimpleOnActionExpandListener.bind(menuItem, new SimpleOnActionExpandListener() { @Override public boolean onMenuItemActionCollapse(MenuItem item) { loadData(); return true; } }); }
Example 7
Source File: SearchActivity.java From WanAndroid with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_search, menu); MenuItem menuItem = menu.findItem(R.id.item_search); //得到SearchView mSearchView = (SearchView)menuItem.getActionView(); mSearchAutoComplete = mSearchView.findViewById(R.id.search_src_text); mSearchView.setMaxWidth(R.dimen.dp_400);//设置最大宽度 mSearchView.setSubmitButtonEnabled(true);//设置是否显示搜索框展开时的提交按钮 mSearchView.setQueryHint(getResources().getString(R.string.searchActivity_hint));//设置输入框提示语 mSearchView.onActionViewExpanded();//设置搜索框直接展开显示。左侧有放大镜(在搜索框中) 右侧无叉叉 有输入内容后有叉叉 不能关闭搜索框 mSearchAutoComplete.setTextColor(getResources().getColor(R.color.white));//设置内容文字颜色 //搜索框文字变化监听,搜索按钮监听 mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { mPresenter.addHistoryRecord(query); mPresenter.loadSearchResquest(query, 0); isLoadMore = false; return false; } @Override public boolean onQueryTextChange(String newText) { mPresenter.clearAllSearchKey(newText); return false; } }); return super.onCreateOptionsMenu(menu); }
Example 8
Source File: BookmarksActivity.java From SimplicityBrowser with MIT License | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_b_h, menu); searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setIconified(true); searchView.setOnQueryTextListener(this); searchView.setQueryHint(getResources().getString(R.string.search_bookmarks)); return true; }
Example 9
Source File: HistoryActivity.java From SimplicityBrowser with MIT License | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_b_h, menu); searchView = (SearchView) menu.findItem(R.id.search).getActionView(); searchView.setIconified(true); searchView.setOnQueryTextListener(this); searchView.setQueryHint(getResources().getString(R.string.search_history)); searchView.setMaxWidth(Integer.MAX_VALUE); return true; }
Example 10
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 11
Source File: DownloadMapActivity.java From PocketMaps with MIT License | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_maps, menu); MenuItem searchItem = menu.findItem(R.id.menu_search_filter); SearchView searchView = (SearchView) searchItem.getActionView(); searchView.setQueryHint(getResources().getString(R.string.search_hint)); searchView.setOnQueryTextListener(this); searchView.setOnSearchClickListener(createHideMenuListener(menu)); searchView.setOnCloseListener(createShowMenuListener(menu)); return true; }
Example 12
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 13
Source File: MainActivity.java From Passbook with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(getResources().getBoolean(R.bool.hide_drawer) ? R.menu.menu_home_small : R.menu.menu_home_large, menu); for(int i = 0; i < menu.size(); ++i) { menu.getItem(i).getIcon().setColorFilter( C.ThemedColors[C.colorTextNormal], PorterDuff.Mode.SRC_ATOP); } SearchView searchView = (SearchView)menu.findItem(R.id.action_search).getActionView(); searchView.setQueryHint(getString(R.string.search)); searchView.setOnQueryTextListener(this); return true; }
Example 14
Source File: MainActivity.java From Passbook with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(getResources().getBoolean(R.bool.hide_drawer) ? R.menu.menu_home_small : R.menu.menu_home_large, menu); for(int i = 0; i < menu.size(); ++i) { menu.getItem(i).getIcon().setColorFilter( C.ThemedColors[C.colorTextNormal], PorterDuff.Mode.SRC_ATOP); } SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); searchView.setQueryHint(getString(R.string.search)); searchView.setOnQueryTextListener(this); return true; }
Example 15
Source File: MainActivity.java From arcgis-runtime-samples-android with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // inflate address search view mAddressSearchView = (SearchView) findViewById(R.id.addressSearchView); mAddressSearchView.setIconified(false); mAddressSearchView.setFocusable(false); mAddressSearchView.setQueryHint(getResources().getString(R.string.address_search_hint)); // define pin drawable BitmapDrawable pinDrawable = (BitmapDrawable) ContextCompat.getDrawable(this, R.drawable.pin); try { mPinSourceSymbol = PictureMarkerSymbol.createAsync(pinDrawable).get(); } catch (InterruptedException | ExecutionException e) { Log.e(TAG, "Picture Marker Symbol error: " + e.getMessage()); Toast.makeText(getApplicationContext(), "Failed to load pin drawable.", Toast.LENGTH_LONG).show(); } // set pin to half of native size mPinSourceSymbol.setWidth(19f); mPinSourceSymbol.setHeight(72f); // create a LocatorTask from an online service mLocatorTask = new LocatorTask("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"); // inflate MapView from layout mMapView = (MapView) findViewById(R.id.mapView); // create a map with the BasemapType topographic final ArcGISMap map = new ArcGISMap(Basemap.createStreetsVector()); // set the map to be displayed in this view mMapView.setMap(map); // set the map viewpoint to start over North America mMapView.setViewpoint(new Viewpoint(40, -100, 100000000)); // add listener to handle screen taps mMapView.setOnTouchListener(new DefaultMapViewOnTouchListener(this, mMapView) { @Override public boolean onSingleTapConfirmed(MotionEvent motionEvent) { identifyGraphic(motionEvent); return true; } }); // define the graphics overlay mGraphicsOverlay = new GraphicsOverlay(); setupAddressSearchView(); }