searchview

How to remove focus from SearchView?

*爱你&永不变心* 提交于 2019-12-03 09:34:37
I want to remove focus and text from SearchView in onResume() . I tried searchView.clearFocus() but it is not working. This is my xml code: <SearchView android:id="@+id/searchView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignBottom="@+id/toolbar" android:layout_alignTop="@+id/toolbar" android:layout_centerVertical="true" android:layout_marginBottom="4dp" android:layout_marginTop="4dp" android:iconifiedByDefault="false" android:paddingLeft="16dp" android:paddingRight="16dp" /> I want to remove focus and text from SearchView in onResume() To

How can I get onBackPressed() while SearchView is activated?

邮差的信 提交于 2019-12-03 09:28:45
How can I handle onBackPressed() at search mode? I have implemented the search at the ActionBar , and I want to handle onBackPressed() . Edit: At MainActivity I have added this, but it only gets notified when search is closed @Override public void onBackPressed() { mMenu.findItem(R.id.menu_eye).setVisible(true); mMenu.findItem(R.id.menu_layers).setVisible(true); super.onBackPressed(); }; and my listener for search action looks like this: import com.cyrilmottier.polaris.PolarisMapView; import android.app.SearchManager.OnCancelListener; import android.content.Context; import android.view.Menu;

How to make SearchView lose focus and collapse when clicking elsewhere on activity

China☆狼群 提交于 2019-12-03 07:23:28
In my app, I'm making a search interface in which the SearchView collapses and expands when it loses and gains focus respectively. However, the losing focus thing is only happening in two cases: When the back button is pressed. When the home icon beside the SearchView is pressed. I want it to lose focus (and hence collapse) if the user clicks not only on these two things, but anywhere else on the screen (e.g., any button or any blank portion of the screen without a view on it). Pankaj Singhal Well I found out the following solution. I used setOnTouchListener on every view that is not an

SearchView using AppCompat

≡放荡痞女 提交于 2019-12-03 06:57:52
问题 I implemented SearchView in Actionbar before using appcompat.v7 but when I want to use the SearchView with support library v7 it shows null exception In style <item android:id="@+id/action_search" android:title="@string/action_search" android:icon="@drawable/ic_action_search" app:showAsAction="always|collapseActionView" android:actionViewClass="android.support.v7.widget.SearchView" /> In Java Class: @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu

Implementing SearchView in Toolbar with Fragments

痴心易碎 提交于 2019-12-03 06:30:16
CURRENT SCENARIO My app home page consists of navigation drawer, therefore I am having views loaded as fragments. I also have search icon in toolbar. I implemented it in menu.xml . Next step I implemented SearchView for search icon by following answer on this question Implementing search in Toolbar . This is working fine as search view shows and can also be dismissed. PROBLEM I can implement search query for the search view but I cannot understand how to proceed. Problem is that onCreateOptionsMenu is in Activity and all code for search view is in the Activity . What I don't understand is data

Change TextColor in SearchView using Android Toolbar

不打扰是莪最后的温柔 提交于 2019-12-03 05:57:07
I have the following problem. I've setup my Actionbar to use a Toolbar instead using the API 21 with the appcompat-v7:21. The textColorPrimary style tag is configured to use the color @android:color/white , so all the titles in the new Android Toolbar will have a white text color (so far so good). Now I´ve added a SearchView, and setup a custom background to it like this: <style name="AppTheme.Base" parent="Theme.AppCompat.Light"> <item name="colorPrimary">@color/action_bar_background</item> <item name="colorPrimaryDark">@color/status_background</item> <item name="android:windowNoTitle">true<

Delay call to onQueryTextChange() in SearchView.OnQueryTextListener with SearchView

余生长醉 提交于 2019-12-03 05:25:25
Using a SearchView in my application. Is there anyway in which I can make the call to onQueryTextChange() method delayed. Like, when user type a sequence of characters, he must wait before this method gets called. This wait should not depend on number of characters typed yet but a small pause is required before method being hit. I want to pause because, as the user types into the search view, a request with the string will be made to server to request the matched data, and then I will populate my ListView according to suggestions. Activity information (if required) : Implements SearchView

Change appcompat's SearchView text and hint color

耗尽温柔 提交于 2019-12-03 04:47:19
Does anybody know how to change the text color of the appcompat SearchView? I've spent 2 hours and tried several suggestions from SO and none works. Here is my code: <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:espacios="http://schemas.android.com/apk/res-auto" > <item android:id="@+id/layer_switcher_button" android:icon="@drawable/b_categorias" android:title="@string/menu_layer_switcher_title" espacios:showAsAction="ifRoom|collapseActionView"/> <item android:id="@+id/action_search" android:icon="@drawable/b_buscar" android:title="@string/menu_search_title" espacios

Start new activity from SearchView

≡放荡痞女 提交于 2019-12-03 04:24:49
问题 I have 2 activities: the first has a action bar with a search view, the second should display the results of the search query. androidmanifest: <activity android:name=".SearchActivity" ... android:launchMode="singleTop"> <meta-data android:name="android.app.searchable" android:resource="@xml/searchable" /> ... </activity> <activity android:name=".ResultsActivity" ... <intent-filter> <action android:name="android.intent.action.SEARCH" /> </intent-filter> </activity> searchable.xml <searchable

Android SearchView empty string

喜你入骨 提交于 2019-12-03 03:27:08
I'm trying to use a SearchView and I got everything to work, except when I want to search an empty string. The onQueryTextChange does react when I remove the last character, but I want the user to be able to press the search button when the searchfield is empty. final SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextChange(String newText) { // Do something return true; } @Override public boolean onQueryTextSubmit(String query) { // Do something return true; } }; searchView.setOnQueryTextListener(queryTextListener); I