searchview

MenuItemCompat.setOnActionExpandListener deprecated

≡放荡痞女 提交于 2019-11-28 09:20:28
I have some code that sets a boolean if the search view is open or not. MenuItemCompat.setOnActionExpandListener(action_search, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item){ isSearch = true; return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item){ isSearch = false; return true; } }); It works. I'm happy with the way it responds. However, it it shows as deprecated, the setOnActionExpandListener is crossed out with the warning android.support.v4.view.MenuItemCompat.setOnActionExpandListener is deprecated

How to disable searchview?

南楼画角 提交于 2019-11-28 08:25:32
问题 Can you help me on how to disable searchview when button is pressed? I'm trying this code: searchView.setEnabled(false); searchView.setFocusableInTouchMode(false); searchView.clearFocus(); but it seems not working. I can still input text in searchview. Thanks.. :)) 回答1: You can use: searchView.clearFocus(); and if you want to hide it using: searchView.setVisibility(View.GONE); 回答2: All above questions don't work for me. Becase SearchView is a ViewGroup, so we have to disable all its child

How to build Gmail like search box in the action bar?

邮差的信 提交于 2019-11-28 04:34:50
I am currently using SearchView widget inside ActionBarcompat to filter a list while searching. When the user starts entering text the ListView in the main layout updates with an Adapter to filter the results. I do this by implementing a OnQueryTextListener and filter the results on each key stroke. Instead, I want to create a Gmail like search box with auto suggest list generated and no changes to the underlying view I have went through this tutorial that uses the SearchView component but it requires a searchable activity. I want the drop-down to be over the MainActivity where I have the

Turn AutoCompleteTextView into a SearchView in ActionBar instead

大憨熊 提交于 2019-11-28 02:50:16
I have a AutoCompleteTextView which gives user auto-completion search result from Google Places API . Once I was done I discovered SearchView and how it can be placed in the ActionBar . I checked out the SearchView example provided by google and added it to my application as a starting point (it lists the installed applications) but I don´t know how to proceed from here. I want to have the same functionality as AutoCompleteTextView but use the SearchView instead. Any suggestion? The whole class is provided below. import java.io.BufferedReader; import java.io.IOException; import java.io

Android: how do I get SearchView close button to return the setQueryHint()?

白昼怎懂夜的黑 提交于 2019-11-28 02:26:42
I have a Search icon in my toolbar that searches a RecyclerView list. Pic 1: When the icon is clicked, the toolbar shows the SearchView's setQueryHint " Search here...". Pic 2: When a character is entered on the SearchView line, in this case the number "4", it is then searched in the RecyclerView list. If the character is not found, a close button "x" appears to the right of the character: Pic 3: My problem is that the default behavior when clicking on the close button "x" is to close the SearchView which returns the view back to Pic 1, the initial icon View. I would like to have the View

Create “history” to SearchView on ActionBar

耗尽温柔 提交于 2019-11-28 01:48:05
问题 I want to have history on my SearchView, I've been googling around, and the only sensible(?) tutorial I found was this, but that's just for like Gingerbread, not API>14. Then I found this code: String[] columnNames = {"_id","text"}; MatrixCursor cursor = new MatrixCursor(columnNames); String[] array = {"Snääälla", "bla bla bla", "Jävla piss"}; //if strings are in resources String[] temp = new String[2]; int id = 0; for(String item : array){ temp[0] = Integer.toString(id++); temp[1] = item;

Android expanded SearchView makes other ActionBar items disappear

淺唱寂寞╮ 提交于 2019-11-28 01:27:48
问题 I'm facing some problems with a SearchView in a Contextual Action Bar called by a Fragment. The major one is that when my SearchView is expanded, it makes disappear all other items in action bar (except the closing button) even if there's some unused space, like you can see in this screenshot: Screenshot Furthermore, I'm also having the same exact problem discussed in this question: ActionBar always expanded SearchView with the icon inside This is the XML code of my SearchView: <?xml version=

SearchView.OnCloseListener does not get invoked

喜欢而已 提交于 2019-11-28 01:16:19
Im using an action bar and adding a searchView to it. I have implemented the searchView.onCLoseListener but this does not seem to be getting invoked. Any suggestions ? My code looks something like this : SearchView searchView = new SearchView(getContext()); searchView.setOnCloseListener(new OnCloseListener() { public boolean onClose() { searchView.setVisibility(SearchView.GONE); // Do Something return true; } }); I ran into same problem on android 4.1.1. Looks like it is a known bug: https://code.google.com/p/android/issues/detail?id=25758 Anyway, as a workaround i used state change listener

[Android search widget]How to hide the close button in search view by default?

谁都会走 提交于 2019-11-27 21:22:38
问题 I have implemented an android SearchView in ActionBar . When the SearchView gains focus, the close button [x] at the right shows up. I took a look at other android native apps, like Contacts and Gmail. The close button is not shown when the SearchView gains focus. How to set my SearchView behave like that? 回答1: Setting searchView.setIconifiedByDefault(false) will disable collapsing the search view and also remove the close button. 回答2: I faced the same problem with android.support.v7.widget

Android SearchView.OnQueryTextListener OnQueryTextSubmit not fired on empty query string

爱⌒轻易说出口 提交于 2019-11-27 20:06:28
I am using Android 4.1.2. I have a SearchView widget on an ActionBar . Documentation on SearchView.OnQueryTextListener from the android developer site states that onQueryTextSubmit is fired when "Called when the user submits the query. This could be due to a key press on the keyboard or due to pressing a submit button." This does not happen if the search query is empty. I need this to fire on an empty query to clear the search filter of a ListView. Is this a bug or am I doing something wrong? It is not a bug, the source code deliberately checks against null and empty values: private void