Example usage for android.widget SearchView setQueryHint

List of usage examples for android.widget SearchView setQueryHint

Introduction

In this page you can find the example usage for android.widget SearchView setQueryHint.

Prototype

public void setQueryHint(@Nullable CharSequence hint) 

Source Link

Document

Sets the hint text to display in the query text field.

Usage

From source file:com.melchor629.musicote.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    //Create the search view
    SearchView searchView = new SearchView(getActionBar().getThemedContext());
    searchView.setQueryHint(getResources().getString(R.string.menu_search));
    searchView.setOnQueryTextListener(this);

    menu.add("Search")
            .setIcon(new IconDrawable(this, Iconify.IconValue.fa_search).color(Color.WHITE).actionBarSize())//android.R.drawable.ic_menu_search)
            .setActionView(searchView)//w  w  w.  j  a v a2s . co m
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    getMenuInflater().inflate(R.menu.main, menu);

    menu.findItem(R.id.ajustesm)
            .setIcon(new IconDrawable(this, Iconify.IconValue.fa_cogs).color(Color.WHITE).actionBarSize());

    menu.findItem(R.id.parar)
            .setIcon(new IconDrawable(this, Iconify.IconValue.fa_music).color(Color.WHITE).actionBarSize());
    return true;
}

From source file:com.hybris.mobile.activity.StoreLocatorActivity.java

/**
 * Menu methods/*from   w w w  .ja  va  2  s. c o  m*/
 */
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    MenuInflater inflater = this.getMenuInflater();
    inflater.inflate(R.menu.store_finder, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchViewMenuItem = menu.findItem(R.id.store_search);
    this.mSearchView = searchViewMenuItem;
    SearchView searchView = ((SearchView) searchViewMenuItem.getActionView());

    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(true);
    searchView.setQueryHint(getResources().getString(R.string.store_search_hint));
    searchView.setOnQueryTextListener(this);

    return true;
}

From source file:com.wearapp.PickFriendsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    //Log.w(TAG, "IN createing Search friends OptionsMenu");
    // Inflate the options menu from XML
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_menu, menu);
    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(/* w w  w .  j  a v a2s  . c  o m*/
            searchManager.getSearchableInfo(new ComponentName("com.wearapp", "com.wearapp.HistoryActivity")));
    //searchView.setSearchableInfo(searchManager.getSearchableInfo(this.getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
    searchView.setQueryHint(getResources().getString(R.string.search_friend_hint));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            // TODO Auto-generated method stub
            return false;
        }

        @Override
        public boolean onQueryTextChange(String keyword) {
            // TODO Auto-generated method stub         

            selectedUsers.addAll(selectedUsers_temp1);
            //TODO need update FacebookSDK to 2.6 version 
            friendPickerFragment.setSelection(selectedUsers);

            searchterm = keyword;
            friendPickerFragment.setFilter(new GraphObjectFilter<GraphUser>() {
                @Override
                public boolean includeItem(GraphUser graphObject) {
                    // TODO Auto-generated method stub                               
                    Pattern p = Pattern.compile(searchterm, Pattern.CASE_INSENSITIVE);
                    Matcher m = p.matcher(graphObject.getName());
                    if (m.find()) {
                        return true;
                    }
                    return false;
                }
            });

            friendPickerFragment.loadData(true);

            return false;
        }

    });

    return true;
}

From source file:net.mypapit.mobile.myrepeater.RepeaterListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.display_map, menu);

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setIconifiedByDefault(false);
        searchView.setQueryHint("part of repeater callsign");

        SearchView.OnQueryTextListener textChangeListener = new SearchView.OnQueryTextListener() {

            @Override/*from w ww  .  j a va2 s  .c  o  m*/
            public boolean onQueryTextSubmit(String searchText) {

                adapter.getFilter().filter(searchText);
                Log.d("MYRepeater", "search: " + searchText);
                adapter.notifyDataSetChanged();
                return true;
            }

            @Override
            public boolean onQueryTextChange(String searchText) {
                // TODO Auto-generated method stub
                adapter.getFilter().filter(searchText);
                adapter.notifyDataSetChanged();
                return true;
            }
        };

        searchView.setOnQueryTextListener(textChangeListener);
    }

    return super.onCreateOptionsMenu(menu);
}