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

The following examples show how to use android.widget.SearchView#setFocusable() . 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: SearchableActivity.java    From RhymeMusic with Apache License 2.0 5 votes vote down vote up
private void initComponents()
    {
        application = (MusicApplication) getApplication();

        /*搜索结果为空时,显示的提示信息*/
        textTips = (TextView) findViewById(R.id.text_tips);

        /*按钮类组件初始化*/
        searchBack = (ImageButton) findViewById(R.id.image_search_back);
        searchOption = (ImageButton) findViewById(R.id.image_search_option);
        searchBack.setOnClickListener(this);
        searchOption.setOnClickListener(this);

        /*列表组件初始化*/
        listView = (ListView) findViewById(R.id.list_search_result);
        listView.setOnItemClickListener(this);
        listView.setVisibility(View.INVISIBLE);
        loadData();

        /*搜索组件初始化*/
        searchView = (SearchView) findViewById(R.id.view_search);
        searchView.setOnQueryTextListener(this);
        searchView.onActionViewExpanded(); // 默认出现点击输入状态
        searchView.setFocusable(false);
        searchView.clearFocus();
//        searchView.setSubmitButtonEnabled(true);

    }