searchview

Android abs with SearchView, onQueryTextListener not working

只愿长相守 提交于 2019-12-06 07:46:03
问题 I'm trying to use the SearchView Support v4 version with action bar sherlock. So i have my search button in the action bar -> when i touch it the keyboard show up and the searchBar too. My problem is that i need to use the listeners onQueryTextSubmit and onQueryTextChange but they are never fired. I need to use the searh query string and do custom stuff with it. Here is the full activity.java public class ActivityMain extends SherlockFragmentActivity implements OnQueryTextListener,

How to type text on a SearchView using espresso

大城市里の小女人 提交于 2019-12-06 07:31:48
TypeText doesn't seem to work with SearchView . onView(withId(R.id.yt_search_box)) .perform(typeText("how is the weather?")); gives the error: Error performing 'type text(how is the weather?)' on view 'with id:../yt_search_box' For anyone that bump into this problem too, the solution is to write a ViewAction for the type SearchView, since the typeText only supports TextEditView Here my solution: public static ViewAction typeSearchViewText(final String text){ return new ViewAction(){ @Override public Matcher<View> getConstraints() { //Ensure that only apply if it is a SearchView and if it is

Wait until the user stops typing before executing a heavy search in searchview

我与影子孤独终老i 提交于 2019-12-06 07:19:39
问题 Search is central in my app and I need it to work well. Right now I have a SearchView. I need to display the results inline, so I'm using this code. searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { srl.setVisibility(View.GONE); return false; } @Override public boolean onQueryTextChange(String query) { currentQuery = query; if (query.length()>= 3) { searchFor(currentQuery); } else { srl.setVisibility(View.GONE);

Can't cast SearchView in Fragment (AppCompat)

空扰寡人 提交于 2019-12-06 05:47:49
问题 I'm trying to listen to text changes in my SearchView from a Fragment but it fails on this line: menu.findItem(R.id.action_search); Exception: java.lang.ClassCastException: android.support.v7.internal.view.menu.MenuItemWrapperJB cannot be cast to android.support.v7.widget.SearchView at se.xxx.xxx.FragmentList.onCreateOptionsMenu(FragmentList.java:155) My onCreateOptionsMenu (in Fragment): @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu

How to set adapter to searchview in actionbar

巧了我就是萌 提交于 2019-12-06 04:16:05
问题 Setting custom values to Searchview Adapter like we do in autocomplete and passing array string I tried this code: private void setupSearchView(MenuItem searchItem) { if (isAlwaysExpanded()) { mSearchView.setIconifiedByDefault(false); } else { searchItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW); } SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); if (searchManager != null) { List<SearchableInfo>

Reusing Action Bar in all activities of application

时间秒杀一切 提交于 2019-12-06 03:45:57
I have created a MenuActivity which is having an Action Bar and an Split Action Bar. I want to use this actionbar and splitactionbar view for all activities in my application. I am a newbie to android so can somebody guide me stepwise about this. Also I am trying to put the search icon on actionbar which is right now appearing on SplitActionBar. I have four icons on SplitActionBar and i want to show search icon on the actionbar not on the SplitActionBar. The search icon is a SearchView item which when clicked expands on ActionBar, which is very untidy. I want it to appear on rightmost position

Getting a SearchView with MenuItemCompat (Android)

强颜欢笑 提交于 2019-12-06 00:56:02
问题 I am trying to implement the SearchView ActionBar item as android developers says but I am having some trouble. (http://developer.android.com/guide/topics/ui/actionbar.html). There are two mistakes that although I have looked for a lot, I have not been able to find the solution. 1) I have a problem with the class MenuItemCompat. It says: The method getActionView(MenuItem) is undefined for the type MenuItemCompat I can only use for this class the following methods: setShowAsAction(item,

Android - cannot find TextView inside SearchWidget when using Android Support library

╄→尐↘猪︶ㄣ 提交于 2019-12-05 23:46:31
I used following snippet to find TextView inside SearchView widget. int autoCompleteTextViewID = getResources().getIdentifier("android:id/search_src_text", null, null); mQueryTextView = (AutoCompleteTextView) searchView.findViewById(autoCompleteTextViewID); However when switching to android.support.v7.appcompat support library, it does not work any more. I guess it is because support library does not use android: prefix for "android:id/search_src_text", but I have no idea what should it be. I tried getResources().getIdentifier("android.support.v7.appcompat:id/search_src_text", null, null); P.S

Styling the SearchView Widget using support library v21

隐身守侯 提交于 2019-12-05 21:58:36
问题 I'm trying to style the SearchView widget using the new AppCompat v21, but I'm facing some problems. No matter what layout I set on "suggestionRowLayout" attribute, it does nothing at all. The suggestion dropdown list of the SearchView remains the same way. Other problem that I'm having is when the "accent color" is the same color as the "primary color", in the searchview is impossible to distinguish where is the caret. Do you know how can I change the accent color in the SearchView to only

Show selection from suggestion list in Android searchview

自古美人都是妖i 提交于 2019-12-05 18:03:58
问题 I have a searchview with suggestion list. If the user selects an item from the list, a new intent is sent and I can apply my filter, but the search view remains empty. If I update the search view in onNewIntent with setQuery (see below), the effect is that the selected item is shown in the search view, but the suggestion list pops up again. Can I avoid that and only show the current query text within the search view without the suggestion list popping up? @Override protected void onNewIntent