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.jaspersoft.android.jaspermobile.activities.repository.fragment.SearchControllerFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setQueryHint(getString(R.string.s_hint));
    searchView.setOnQueryTextListener(this);
}

From source file:org.bwgz.quotation.activity.QuotationsActivity.java

public boolean onCreateOptionsMenu(final Menu menu) {
    Log.d(TAG, String.format("onCreateOptionsMenu - menu: %s", menu));

    getMenuInflater().inflate(R.menu.options_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setQueryHint(getString(R.string.search_keyword));

    final ListView drawerView = (ListView) findViewById(R.id.drawer_view);
    DrawerAdapter adapter = new DrawerAdapter(getResources().getStringArray(R.array.quotations_drawer), 1);
    drawerView.setAdapter(adapter);/*  w w w.  j a va  2  s . co m*/
    drawerView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG, String.format("drawer - onItemClick - parent: %s  view: %s  position: %d  id: %d",
                    parent, view, position, id));

            if (id == 0) {
                drawerLayout.closeDrawer(drawerView);
                startActivity(new Intent(parent.getContext(), HomeActivity.class));
            }
        }
    });

    return true;
}

From source file:org.bwgz.quotation.activity.SubjectsActivity.java

public boolean onCreateOptionsMenu(final Menu menu) {
    Log.d(TAG, String.format("onCreateOptionsMenu - menu: %s", menu));

    getMenuInflater().inflate(R.menu.options_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setQueryHint(getString(R.string.search_subject));

    final ListView drawerView = (ListView) findViewById(R.id.drawer_view);
    DrawerAdapter adapter = new DrawerAdapter(getResources().getStringArray(R.array.subjects_drawer), 1);
    drawerView.setAdapter(adapter);/*from  w ww .j a  v  a  2  s.c om*/
    drawerView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG, String.format("drawer - onItemClick - parent: %s  view: %s  position: %d  id: %d",
                    parent, view, position, id));

            if (id == 0) {
                drawerLayout.closeDrawer(drawerView);
                startActivity(new Intent(parent.getContext(), HomeActivity.class));
            }
        }
    });

    return true;
}

From source file:net.ustyugov.jtalk.activity.XMLConsole.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.xml, menu);//from  ww  w  . j a v a  2 s. c  o  m

    MenuItem.OnActionExpandListener listener = new MenuItem.OnActionExpandListener() {
        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            searchString = "";
            updateList();
            return true;
        }

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            return true;
        }
    };

    SearchView searchView = new SearchView(this);
    searchView.setQueryHint(getString(android.R.string.search_go));
    searchView.setSubmitButtonEnabled(true);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }

        @Override
        public boolean onQueryTextSubmit(String query) {
            searchString = query;
            updateList();
            return true;
        }
    });

    MenuItem item = menu.findItem(R.id.search);
    item.setActionView(searchView);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
    item.setOnActionExpandListener(listener);
    return super.onCreateOptionsMenu(menu);
}

From source file:org.bwgz.quotation.activity.SearchResultsActivity.java

private void setSearchHint(Menu menu, int type) {
    int hintId = 0;

    switch (type) {
    case FreebaseSearch.SEARCH_TYPE_KEYWORD:
        hintId = R.string.search_keyword;
        break;//w w w  .ja  v  a 2  s  . c  om
    case FreebaseSearch.SEARCH_TYPE_AUTHOR:
        hintId = R.string.search_author;
        break;
    case FreebaseSearch.SEARCH_TYPE_SUBJECT:
        hintId = R.string.search_subject;
        break;
    }

    if (hintId != 0) {
        String hint = getString(hintId);

        if (hint != null) {
            SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
            searchView.setQueryHint(hint);
        }
    }
}

From source file:br.com.GUI.perfil.MeusAlunos.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.adicionar_aluno_actions, menu);

    final SearchView searchView = new SearchView(getActivity().getActionBar().getThemedContext());
    searchView.setQueryHint("Search");

    menu.add(Menu.NONE, Menu.NONE, 1, "@string").setIcon(android.R.drawable.ic_menu_search)
            .setActionView(searchView)/*from w w w .  j a  v a 2s . co m*/
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    searchView.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            if (newText.length() > 0) {
                // Search
                atualizarMeusAlunos(newText.toString());

            } else {
                // Do something when there's no input
                atualizarMeusAlunos(newText.toString());
            }
            return false;
        }

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

From source file:br.com.GUI.aulas.Agenda.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.agenda_actions, menu);

    final SearchView searchView = new SearchView(getActivity().getActionBar().getThemedContext());
    searchView.setQueryHint("Search");

    menu.add(Menu.NONE, Menu.NONE, 1, "@string").setIcon(android.R.drawable.ic_menu_search)
            .setActionView(searchView)//from  w ww .  j  a v  a  2s. co m
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    searchView.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            if (newText.length() > 0) {
                // Search
                atualizarAgenda(newText.toString());

            } else {
                // Do something when there's no input
                atualizarAgenda(newText.toString());
            }
            return false;
        }

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

From source file:org.bwgz.quotation.activity.HomeActivity.java

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    Log.d(TAG, String.format("onCreateOptionsMenu - menu: %s", menu));

    getMenuInflater().inflate(R.menu.options_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setQueryHint(getString(R.string.search_keyword));

    final ListView drawerView = (ListView) findViewById(R.id.drawer);
    DrawerAdapter adapter = new DrawerAdapter(getResources().getStringArray(R.array.home_drawer), 0);
    drawerView.setAdapter(adapter);//from w  w  w.j a v a2s  . c om
    drawerView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.d(TAG, String.format("drawer - onItemClick - parent: %s  view: %s  position: %d  id: %d",
                    parent, view, position, id));

            drawerLayout.closeDrawer(drawerView);

            if (id == 1) {
                Intent intent = new Intent(parent.getContext(), QuotationsActivity.class);
                intent.putExtra(CategoryActivity.EXTRA_ITEM, QuotationsActivity.QUOTATIONS_ITEM_BOOKMARKS);
                startActivity(intent);
            }
        }
    });

    return true;
}

From source file:com.example.snowball.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main, menu);
    MenuItem searchItem = menu.findItem(R.id.action_websearch);
    SearchView searchView = (SearchView) searchItem.getActionView();
    searchView.setQueryHint("///");
    searchView.setQueryRefinementEnabled(false);
    // SearchView
    return super.onCreateOptionsMenu(menu);
}

From source file:br.com.GUI.perfil.BuscarUsuario.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.buscar_usuario, menu);

    final SearchView searchView = new SearchView(this.getActionBar().getThemedContext());
    searchView.setQueryHint("Search");

    menu.add(Menu.NONE, Menu.NONE, 1, "@string").setIcon(android.R.drawable.ic_menu_search)
            .setActionView(searchView)/*from   ww w  .  j  av  a  2 s. c o m*/
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    searchView.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            /* if (newText.length() > 0) {
                if(pref.getString("tipo", null).equals("personal")){
                   pesquisarAluno(newText.toString());
                }else if(pref.getString("tipo", null).equals("aluno")){
                   pesquisarPersonal(newText.toString());
                }
                    
             } else {
                if(pref.getString("tipo", null).equals("personal")){
                   pesquisarAluno("");
                }else if(pref.getString("tipo", null).equals("aluno")){
                   pesquisarPersonal("");
                }
                        
            }*/
            return false;
        }

        @Override
        public boolean onQueryTextSubmit(String arg0) {
            if (pref.getString("tipo", null).equals("personal")) {
                pesquisarAluno(arg0);
            } else if (pref.getString("tipo", null).equals("aluno")) {
                pesquisarPersonal(arg0);
            }

            return false;
        }
    });
    return true;
}