當前位置: 首頁>>代碼示例>>Java>>正文


Java SearchView.requestFocus方法代碼示例

本文整理匯總了Java中android.support.v7.widget.SearchView.requestFocus方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchView.requestFocus方法的具體用法?Java SearchView.requestFocus怎麽用?Java SearchView.requestFocus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v7.widget.SearchView的用法示例。


在下文中一共展示了SearchView.requestFocus方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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.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

示例2: setupSearchView

import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
private void setupSearchView(Menu menu) {
    ActionBar actionBar = getSupportActionBar();
    Context context = actionBar != null ? actionBar.getThemedContext() : this;
    SearchView searchView = new SearchView(context);
    searchView.setIconifiedByDefault(false);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String queryText) {
            mEasyRecycleAdapter.setItems(new ArrayList<PointOfInterest>());
            if (queryText.length() > 0) {
                getAutocompleteResults(queryText);
            } else {
                mSubscriptions.unsubscribe();
                mProgressBar.setVisibility(View.GONE);
            }
            return false;
        }
    });
    searchView.requestFocus();
    menu.findItem(R.id.action_search).setActionView(searchView);
}
 
開發者ID:sathishmscict,項目名稱:Pickr,代碼行數:27,代碼來源:SearchActivity.java

示例3: 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


注:本文中的android.support.v7.widget.SearchView.requestFocus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。