当前位置: 首页>>代码示例>>Java>>正文


Java SearchView.setSearchableInfo方法代码示例

本文整理汇总了Java中android.support.v7.widget.SearchView.setSearchableInfo方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.setSearchableInfo方法的具体用法?Java SearchView.setSearchableInfo怎么用?Java SearchView.setSearchableInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.SearchView的用法示例。


在下文中一共展示了SearchView.setSearchableInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_menu, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.action_filter).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    searchView.setOnCloseListener(this);
    searchView.setOnQueryTextListener(this);
    // setOnSuggestionListener -> for selection of a suggestion
    // setSuggestionsAdapter

    return true;
}
 
开发者ID:ramack,项目名称:ActivityDiary,代码行数:19,代码来源:MainActivity.java

示例2: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_menu, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search_btn).getActionView();

    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
    searchView.setMaxWidth(Integer.MAX_VALUE);
    searchView.requestFocus(1);
    //searchView.setSubmitButtonEnabled(true);


    return true;
}
 
开发者ID:Socialate,项目名称:furry-sniffle,代码行数:20,代码来源:MainActivity.java

示例3: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    try {
        // inflate the menu items for use in the action bar
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu_main_actionbar, menu);

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

    }catch(Exception ex){
        LogHelper.e(LOG_TAG, ex.getMessage());
    }finally {
        return super.onCreateOptionsMenu(menu);

    }
}
 
开发者ID:malah-code,项目名称:Open-Quran-Radio,代码行数:23,代码来源:MainActivity.java

示例4: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.nav, menu);

        SearchManager searchManager = (SearchManager)
                getSystemService(Context.SEARCH_SERVICE);

        searchMenuItem = menu.findItem(R.id.action_search);
        searchView = (SearchView) searchMenuItem.getActionView();

        searchView.setSearchableInfo(searchManager.
                getSearchableInfo(getComponentName()));
        searchView.setSubmitButtonEnabled(true);

    return true;
}
 
开发者ID:doljko,项目名称:youth-health,代码行数:18,代码来源:MainActivity.java

示例5: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the options menu from XML
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_menu, menu);

    SearchManager searchManager = (SearchManager)
            getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();

    searchView.setSearchableInfo(searchManager.
            getSearchableInfo(getComponentName()));
    searchView.setOnQueryTextListener(this);
    MenuItemCompat.setOnActionExpandListener(searchMenuItem, this);

    return true;
}
 
开发者ID:10clouds,项目名称:InifiniteRecyclerView,代码行数:19,代码来源:MainActivity.java

示例6: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.list_menu, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setOnCloseListener(() -> {
        postOnResumeEvents.onNext(new GetPaginatedUsersEvent(viewState == null ? -1 : viewState.getLastId()));
        return false;
    });
    eventObservable = eventObservable.mergeWith(RxSearchView.queryTextChanges(searchView)
            .filter(charSequence -> !charSequence.toString().isEmpty())
            .map(query -> new SearchUsersEvent(query.toString()))
            .throttleLast(100, TimeUnit.MILLISECONDS)
            .debounce(200, TimeUnit.MILLISECONDS)
            .doOnEach(searchUsersEvent -> Log.d("SearchEvent", FIRED)));
    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:Zeyad-37,项目名称:RxRedux,代码行数:19,代码来源:UserListActivity.java

示例7: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {

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

    //init search in the toolbar
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    //listener for click in search button
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            startActivity(new Intent(HomeActivity.this, SearchActivity.class)
                    .putExtra(AppConstants.General.SEARCH_TEXT, query));
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });

    return true;
}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:28,代码来源:HomeActivity.java

示例8: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  super.onCreateOptionsMenu(menu);
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.quran_menu, menu);
  final MenuItem item = menu.findItem(R.id.search);
  final SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
  final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
  searchView.setQueryHint(getString(R.string.search_hint));
  searchView.setSearchableInfo(searchManager.getSearchableInfo(
      new ComponentName(this, SearchActivity.class)));
  return true;
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:14,代码来源:PagerActivity.java

示例9: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_layout, menu);

    SearchManager manager = (SearchManager) getSystemService(SEARCH_SERVICE);

    final SearchView search = (SearchView) menu.findItem(R.id.search).getActionView();
    search.setSearchableInfo(manager.getSearchableInfo(getComponentName()));
    search.setOnQueryTextListener(this);

    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:BakkerTom,项目名称:happy-news,代码行数:13,代码来源:MainActivity.java

示例10: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {

    getMenuInflater().inflate(R.menu.search_navigation, menu);
    MenuItem searchViewItem = menu.findItem(R.id.action_search);

    SearchManager searchManager =
            (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) searchViewItem.getActionView();
    searchView.setQueryHint("Search");
    searchView.setSearchableInfo(searchManager
            .getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);// Do not iconify the widget; expand it by defaul

    SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
        public boolean onQueryTextChange(String newText) {
            // Adapter that will be filtered
            classAdapter.getFilter().filter(newText);
            return true;
        }

        public boolean onQueryTextSubmit(String query) {

            return true;
        }
    };

    searchView.setOnQueryTextListener(queryTextListener);
    return true;
}
 
开发者ID:fga-gpp-mds,项目名称:2017.1-Trezentos,代码行数:31,代码来源:SearchActivity.java

示例11: setupSearchView

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
private void setupSearchView(SearchView searchView) {
    searchView.setIconifiedByDefault(false);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    if (searchManager != null) {
        SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName());
        searchView.setSearchableInfo(searchableInfo);
    }

    searchView.setOnQueryTextListener(this);
    searchView.requestFocus();

    searchView.setMaxWidth(Integer.MAX_VALUE);
}
 
开发者ID:Vavassor,项目名称:Tusky,代码行数:15,代码来源:SearchActivity.java

示例12: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.toolbar_default_menu, menu);
    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchMenuItem = menu.findItem(R.id.action_search);
    mSearchView = (SearchView)mSearchMenuItem.getActionView();
    // Assumes current activity is the searchable activity
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    //searchView.setSubmitButtonEnabled(true);
    mSearchView.setOnQueryTextListener(mSearchViewListener);
    return true;
}
 
开发者ID:adityak368,项目名称:Android-FileBrowser-FilePicker,代码行数:15,代码来源:FileBrowser.java

示例13: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);

    SearchManager searchManager =
            (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView =
            (SearchView) menu.findItem(R.id.action_search).getActionView();
    if (searchManager != null && searchView != null) {
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    }

    return true;
}
 
开发者ID:scaffeinate,项目名称:Inflix,代码行数:15,代码来源:MainActivity.java

示例14: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    SearchManager searchManager =
            (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView =
            (SearchView) menu.findItem(R.id.action_search).getActionView();
    if (searchManager != null && searchView != null) {
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setOnQueryTextListener(this);
    }
    return true;
}
 
开发者ID:scaffeinate,项目名称:Inflix,代码行数:14,代码来源:SearchResultsActivity.java

示例15: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
/**
 * Handles the tasks that need to be performed when the menu is created.
 * Sets the custom menu layout and sets up the search field handlers.
 * @param menu
 * @return
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.choice_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchItem = menu.findItem(R.id.search);
    searchView = (SearchView) searchItem.getActionView();

    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setSubmitButtonEnabled(true);
    searchView.setOnQueryTextListener(this);

    return true;
}
 
开发者ID:digital-voting-pass,项目名称:polling-station-app,代码行数:21,代码来源:ElectionChoiceActivity.java


注:本文中的android.support.v7.widget.SearchView.setSearchableInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。