Example usage for android.app SearchManager getSearchableInfo

List of usage examples for android.app SearchManager getSearchableInfo

Introduction

In this page you can find the example usage for android.app SearchManager getSearchableInfo.

Prototype

public SearchableInfo getSearchableInfo(ComponentName componentName) 

Source Link

Document

Gets information about a searchable activity.

Usage

From source file:com.deliciousdroid.activity.FragmentBaseActivity.java

@TargetApi(11)
public void setupSearch(Menu menu) {
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setSubmitButtonEnabled(false);
    }//from   w  w  w  . j av  a 2s.  c  o m
}

From source file:com.example.android.drinkapp.activities.HomeBackupActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.mainmenu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    //SearchView searchView =
    //       (SearchView) menu.findItem(R.id.action_search).getActionView();
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search));
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    return true;//from   w ww  . j ava2  s .  c  om

}

From source file:ca.rmen.android.poetassistant.main.dictionaries.search.Search.java

public void setSearchView(SearchView searchView) {
    SearchManager searchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
    ComponentName searchableActivityComponentName = new ComponentName(mContext, mContext.getClass());
    searchView.setSearchableInfo(searchManager.getSearchableInfo(searchableActivityComponentName));
}

From source file:com.tinbytes.simplesearchapp.SimpleListViewActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_simple_list_view, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search_animal));
    if (searchView != null) {
        searchView.setOnQueryTextListener(this);
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setIconifiedByDefault(true);
    }/*www .j  av a 2 s  . co m*/
    return true;
}

From source file:in.rab.ordboken.Ordboken.java

public SearchView initSearchView(Activity activity, Menu menu, String query, Boolean focus) {
    SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) activity.findViewById(R.id.mySearchView);

    searchView.setSearchableInfo(/*from  w ww . j  a  va  2s .co m*/
            searchManager.getSearchableInfo(new ComponentName(activity, MainActivity.class)));

    // Hack to get the magnifying glass icon inside the EditText
    searchView.setIconifiedByDefault(true);
    searchView.setIconified(false);

    // Hack to get rid of the collapse button
    searchView.onActionViewExpanded();

    if (!focus) {
        searchView.clearFocus();
    }

    // searchView.setSubmitButtonEnabled(true);
    searchView.setQueryRefinementEnabled(true);

    if (query != null) {
        searchView.setQuery(query, false);
    }

    return searchView;
}

From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.sign_browser.search.SignSearchActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Log.d(TAG, "onCreateOptionsMenu()" + this.hashCode());
    super.onCreateOptionsMenu(menu);
    final MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_sign_browser_search, menu);
    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()));
    return true;// w w  w  .  j  a  v a 2 s .c  om
}

From source file:com.murati.oszk.audiobook.ui.BaseActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    mMenu = menu;//from   w w  w.  j av a  2 s . c o m
    return true;
}

From source file:com.msted.lensrocket.activities.FriendsListActivity.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.friends_list, menu);
    // Associate searchable configuration with the SearchView
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = (SearchView) menu.findItem(R.id.menuSearch).getActionView();
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    mSearchView.setOnQueryTextListener(new OnQueryTextListener() {
        @Override/* ww  w  . j  a  va2 s  .  c  o m*/
        public boolean onQueryTextSubmit(String query) {
            return true;
        }

        @Override
        public boolean onQueryTextChange(final String newText) {
            LensRocketLogger.i(TAG, "Text: " + newText);
            mCurrentName = newText;
            mBtnAddFriend.setEnabled(true);
            mBtnAddFriend.setVisibility(View.VISIBLE);
            mAdapter.getFilter().filter(newText, new FilterListener() {
                @Override
                public void onFilterComplete(int count) {
                    if (mAdapter.getCount() > 0)
                        mLvFriends.setVisibility(View.VISIBLE);
                    else
                        mLvFriends.setVisibility(View.GONE);

                    if (!mCurrentName.equals("")) {
                        mLayoutAddFriend.setVisibility(View.VISIBLE);
                    } else {
                        mLayoutAddFriend.setVisibility(View.GONE);
                    }
                    if (mLensRocketService.getLocalFriendNames().contains(newText))
                        mLayoutAddFriend.setVisibility(View.GONE);
                }
            });
            mLblNewFriendName.setText(mCurrentName);
            return true;
        }
    });
    return true;
}

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  ww.  j  a  v a  2  s  .  com
    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:us.phyxsi.gameshelf.ui.SearchActivity.java

private void setupSearchView() {
    SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    // hint, inputType & ime options seem to be ignored from XML! Set in code
    searchView.setQueryHint(getString(R.string.search_hint));
    searchView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    searchView.setImeOptions(searchView.getImeOptions() | EditorInfo.IME_ACTION_SEARCH
            | EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_FLAG_NO_FULLSCREEN);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override// w  ww  .  j  a  va 2 s  .co  m
        public boolean onQueryTextSubmit(String query) {
            getByTitle(query);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String query) {
            if (TextUtils.isEmpty(query)) {
                clearResults();
            }
            return true;
        }
    });
}