Java Code Examples for android.widget.SearchView#requestFocusFromTouch()

The following examples show how to use android.widget.SearchView#requestFocusFromTouch() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProgrammaticAutocompleteToolbarActivity.java    From android-places-demos with Apache License 2.0 5 votes vote down vote up
private void initSearchView(SearchView searchView) {
    searchView.setQueryHint(getString(R.string.search_a_place));
    searchView.setIconifiedByDefault(false);
    searchView.setFocusable(true);
    searchView.setIconified(false);
    searchView.requestFocusFromTouch();
    searchView.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            progressBar.setIndeterminate(true);

            // Cancel any previous place prediction requests
            handler.removeCallbacksAndMessages(null);

            // Start a new place prediction request in 300 ms
            handler.postDelayed(() -> {
                getPlacePredictions(newText);
            }, 300);
            return true;
        }
    });
}
 
Example 2
Source File: ProgrammaticAutocompleteToolbarActivity.java    From android-places-demos with Apache License 2.0 5 votes vote down vote up
private void initSearchView(SearchView searchView) {
    searchView.setQueryHint(getString(R.string.search_a_place));
    searchView.setIconifiedByDefault(false);
    searchView.setFocusable(true);
    searchView.setIconified(false);
    searchView.requestFocusFromTouch();
    searchView.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            progressBar.setIndeterminate(true);

            // Cancel any previous place prediction requests
            handler.removeCallbacksAndMessages(null);

            // Start a new place prediction request in 300 ms
            handler.postDelayed(() -> {
                getPlacePredictions(newText);
            }, 300);
            return true;
        }
    });
}
 
Example 3
Source File: MainActivity.java    From NoteCrypt with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.database_opened, menu);
    getMenuInflater().inflate(R.menu.main, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchMenuItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setSearchableInfo(searchManager != null ? searchManager.getSearchableInfo(getComponentName()) : null);
    searchView.setIconifiedByDefault(false);
    searchView.requestFocusFromTouch();
    return true;
}