'How to change title in search box?

I tried to add android:title="" that doesn't work.

SearchView searchView = (SearchView) miFind.getActionView(); searchView.setQueryHint("your message");

didn't work as well. enter image description here

private SearchView.OnQueryTextListener onSearch() {
        return new SearchView.OnQueryTextListener(){
            @Override
            public boolean onQueryTextSubmit(String query) {

                WebView mWebView= (WebView) findViewById(R.id.webView);
                mWebView.loadUrl("http://www.example.com" +query);
                return false;
            }
            @Override
            public boolean onQueryTextChange(String newText) {
                return false;
            }
        };

enter image description here



Solution 1:[1]

If you are talking about the search hint, you need use this method from SearchView: setQueryHint

From the documentation:

Sets the hint text to display in the query text field. This overrides any hint specified in the SearchableInfo.

This value may be specified as an empty string to prevent any query hint from being displayed.


Example:

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize">

    <android.support.v7.widget.SearchView
            android:id="@+id/search_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:imeOptions="actionSearch|flagNoExtractUi"
            app:searchHintIcon="@null"
            app:searchIcon="@null"
            app:queryBackground="@null"
            app:submitBackground="@null"/>

</android.support.v7.widget.Toolbar>

Java:

final SearchView searchView = findViewById(R.id.search_view);
searchView.setQueryHint("Your search string");

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1