Java Code Examples for androidx.appcompat.widget.SearchView#setIconified()
The following examples show how to use
androidx.appcompat.widget.SearchView#setIconified() .
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: BaseListActivity.java From materialistic with Apache License 2.0 | 6 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { if (mIsMultiPane) { getMenuInflater().inflate(R.menu.menu_item_compact, menu); } if (isSearchable()) { getMenuInflater().inflate(R.menu.menu_search, menu); MenuItem menuSearch = menu.findItem(R.id.menu_search); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) mActionViewResolver.getActionView(menuSearch); searchView.setSearchableInfo(searchManager.getSearchableInfo( new ComponentName(this, SearchActivity.class))); searchView.setIconified(true); searchView.setQuery("", false); } return super.onCreateOptionsMenu(menu); }
Example 2
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 3
Source File: SearchFragment.java From Jockey with Apache License 2.0 | 6 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.activity_search, menu); MenuItem searchItem = menu.findItem(R.id.menu_library_search); SearchView searchView = (SearchView) searchItem.getActionView(); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { searchView.clearFocus(); return true; } @Override public boolean onQueryTextChange(String newText) { mViewModel.setSearchQuery(newText); return true; } }); searchView.setIconified(false); if (!StringUtils.isEmpty(mViewModel.getSearchQuery())) { searchView.setQuery(mViewModel.getSearchQuery(), true); } }
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: 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 6
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 7
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 8
Source File: MyMusicFragment.java From odyssey with GNU General Public License v3.0 | 5 votes |
/** * Initialize the options menu. * Be sure to call {@link #setHasOptionsMenu} before. * * @param menu The container for the custom options menu. * @param menuInflater The inflater to instantiate the layout. */ @Override public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater menuInflater) { // Inflate the menu; this adds items to the action bar if it is present. menuInflater.inflate(R.menu.options_menu_my_music, menu); mOptionMenu = menu; // get tint color int tintColor = ThemeUtils.getThemeColor(getContext(), R.attr.odyssey_color_text_accent); Drawable drawable = menu.findItem(R.id.action_search).getIcon(); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, tintColor); mOptionMenu.findItem(R.id.action_search).setIcon(drawable); mSearchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); // Check if a search string is saved from before if (mSearchString != null) { // Expand the view mSearchView.setIconified(false); menu.findItem(R.id.action_search).expandActionView(); // Set the query string mSearchView.setQuery(mSearchString, false); OdysseyFragment fragment = mMyMusicPagerAdapter.getRegisteredFragment(mMyMusicViewPager.getCurrentItem()); // Notify the adapter fragment.applyFilter(mSearchString); } mSearchView.setOnQueryTextListener(new SearchTextObserver()); // show recents options only for the albums fragment menu.findItem(R.id.action_show_recent_albums).setVisible(mMyMusicViewPager.getCurrentItem() == 1); super.onCreateOptionsMenu(menu, menuInflater); }
Example 9
Source File: FilesFragment.java From odyssey with GNU General Public License v3.0 | 5 votes |
/** * Initialize the options menu. * Be sure to call {@link #setHasOptionsMenu} before. * * @param menu The container for the custom options menu. * @param menuInflater The inflater to instantiate the layout. */ @Override public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater menuInflater) { // Inflate the menu; this adds items to the action bar if it is present. menuInflater.inflate(R.menu.options_menu_files_fragment, menu); // get tint color int tintColor = ThemeUtils.getThemeColor(getContext(), R.attr.odyssey_color_text_accent); Drawable drawable = menu.findItem(R.id.action_search).getIcon(); drawable = DrawableCompat.wrap(drawable); DrawableCompat.setTint(drawable, tintColor); menu.findItem(R.id.action_search).setIcon(drawable); SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView(); // Check if a search string is saved from before if (mSearchString != null) { // Expand the view searchView.setIconified(false); menu.findItem(R.id.action_search).expandActionView(); // Set the query string searchView.setQuery(mSearchString, false); // Notify the adapter applyFilter(mSearchString); } searchView.setOnQueryTextListener(new SearchTextObserver()); super.onCreateOptionsMenu(menu, menuInflater); }
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: 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(); }