Java Code Examples for android.support.v7.widget.SearchView#setIconified()

The following examples show how to use android.support.v7.widget.SearchView#setIconified() . 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: SearchActivity.java    From QuickNote with Apache License 2.0 6 votes vote down vote up
private void initSearchView(Menu menu) {
    mSearchView = (SearchView) menu.findItem(R.id.menu_search_view).getActionView();
    mSearchView.setFocusable(true);
    mSearchView.setIconified(false);
    mSearchView.requestFocusFromTouch();
    mSearchView.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            searchAndShowResult(query);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String pattern) {
            return false;
        }
    });
}
 
Example 2
Source File: SearchActivity.java    From good-weather with GNU General Public License v3.0 6 votes vote down vote up
private void setupSearchView() {
    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    SearchView searchView = (SearchView) findViewById(R.id.search_view);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconified(false);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            mSearchCityAdapter.getFilter().filter(query);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            mSearchCityAdapter.getFilter().filter(newText);
            return true;
        }
    });
}
 
Example 3
Source File: SearchActivity.java    From ReadMark with Apache License 2.0 5 votes vote down vote up
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_search, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = (SearchView) menu.findItem(R.id.search).getActionView();
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    //展开searchview
    mSearchView.setIconified(false);
    //显示默认框内标签
    mSearchView.setIconifiedByDefault(true);

    mToolbar.setTitle("");
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class);
            intent.putExtra("q", query);
            UIUtils.startActivity(intent);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
    return true;
}
 
Example 4
Source File: SearchActivity.java    From Theogony with MIT License 5 votes vote down vote up
private void setupSearchView(final SearchView searchView) {
    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconified(false); // xml中设置不起作用
    searchView.setOnQueryTextListener(this);
    searchView.setOnCloseListener(new SearchView.OnCloseListener() {
        @Override
        public boolean onClose() {
            return true;
        }
    });
}
 
Example 5
Source File: FriendSearchActivity.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
private void initViews() {
    layout_points = (LinearLayout) findViewById(R.id.layout_points);
    SearchView searchView = (SearchView) findViewById(R.id.search_view);
    //设置显示提交按钮
    searchView.setSubmitButtonEnabled(true);
    //一开始就处于显示SearchView的状态
    searchView.setIconifiedByDefault(false);
    //设置一开始就显示输入框
    searchView.setIconified(true);
    searchView.clearFocus();
    SearchView.SearchAutoComplete editText = (SearchView.SearchAutoComplete) searchView.findViewById(R.id.search_src_text);
    editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            searchFriend(query.trim());
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            if (!newText.isEmpty()) {
                searchFriend(newText);
            }
            return false;
        }
    });
}
 
Example 6
Source File: SearchActivity.java    From ReadMark with Apache License 2.0 5 votes vote down vote up
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_search, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = (SearchView) menu.findItem(R.id.search).getActionView();
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    //展开searchview
    mSearchView.setIconified(false);
    //显示默认框内标签
    mSearchView.setIconifiedByDefault(true);

    mToolbar.setTitle("");
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class);
            intent.putExtra("q", query);
            UIUtils.startActivity(intent);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
    return true;
}
 
Example 7
Source File: BaseActivity.java    From open with GNU General Public License v3.0 5 votes vote down vote up
private void resetSearchView() {
    final SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setQuery("", false);
    searchView.clearFocus();
    searchView.setIconified(true);
    autoCompleteAdapter.resetCursor();
    autoCompleteAdapter.loadSavedSearches();
}
 
Example 8
Source File: GlobalSearchFragment.java    From Android-Remote with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();

    inflater.inflate(R.menu.global_search_menu, menu);

    // Create a listener for search change
    final MenuItem search = menu.findItem(R.id.global_search_menu_search);
    final SearchView searchView = (SearchView) search.getActionView();
    searchView.setIconifiedByDefault(true);
    searchView.setIconified(false);

    final SearchView.OnQueryTextListener queryTextListener
            = new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }

        @Override
        public boolean onQueryTextSubmit(String query) {
            mSwipeRefreshLayout.setRefreshing(true);
            mEmptyView.setRefreshing(true);

            Message msg = Message.obtain();

            msg.obj = ClementineMessageFactory.buildGlobalSearch(query);
            App.ClementineConnection.mHandler.sendMessage(msg);

            hideSoftInput();

            // Set the actionbar title
            mActionBar.setTitle(getResources().getString(R.string.global_search_query, query));
            mActionBar.setSubtitle("/");

            // Query must be empty in order to collapse the search view.
            searchView.setQuery("", false);
            searchView.setIconified(true);

            // Remove currently present adapters
            mAdapters.clear();
            showList();

            return true;
        }
    };
    searchView.setOnQueryTextListener(queryTextListener);
    searchView.setQueryHint(getString(R.string.global_search_search));

    EditText searchText = (EditText) searchView.findViewById(
            android.support.v7.appcompat.R.id.search_src_text);
    searchText.setHintTextColor(ContextCompat.getColor(getActivity(),
            R.color.searchview_edittext_hint));

    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 9
Source File: SearchActivity.java    From CrimeTalk-Reader with Apache License 2.0 2 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {

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

    // Modify some aspects of the SearchView
    final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    final MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setQuery(mQuery, false);
    searchView.setIconified(false);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String s) {

            return false;

        }

        @Override
        public boolean onQueryTextChange(String query) {

            SearchActivity.this.mQuery = query;

            return false;

        }

    });

    final SearchView.SearchAutoComplete searchAutoComplete = (SearchView.SearchAutoComplete)
            searchView.findViewById(R.id.search_src_text);
    searchAutoComplete.setTextColor(getResources().getColor(R.color.white));

    // Recovering from orientation change, try not to have focus
    if (mQuery != null && !mQuery.isEmpty()) {

       searchView.clearFocus();

    }

    return true;

}