當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。