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


Java SearchView.setIconified方法代碼示例

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


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

示例1: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_search_view, menu);

        MenuItem searchItem = menu.findItem(R.id.action_search);
        mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
        mSearchView.setQueryHint("輸入歌曲名查找");

        mSearchView.onActionViewExpanded();// 當展開無輸入內容的時候,沒有關閉的圖標
        mSearchView.setIconified(true);//設置searchView處於展開狀態

//        searchView.setSubmitButtonEnabled(true);
        mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String query) {
                //提交按鈕的點擊事件
                Toast.makeText(SearchViewActivity.this, query, Toast.LENGTH_SHORT).show();
                return true;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                //當輸入框內容改變的時候回調
//                Log.i(TAG,"內容: " + newText);
                quertMusic(newText);
                return true;
            }
        });


        mSearchAutoComplete = (SearchView.SearchAutoComplete) mSearchView.findViewById(R.id.search_src_text);

        //設置輸入框內容文字和提示文字的顏色
        mSearchAutoComplete.setHintTextColor(getResources().getColor(android.R.color.white));
        mSearchAutoComplete.setTextColor(getResources().getColor(android.R.color.white));

        return super.onCreateOptionsMenu(menu);
    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:39,代碼來源:SearchViewActivity.java

示例2: onPrepareOptionsMenu

import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
    searchItem = menu.findItem(R.id.search);
    searchItem.setOnActionExpandListener(new SearchViewExpandListener(menu));

    searchView = (SearchView) searchItem.getActionView();
    searchView.setIconified(false);
    onQueryTextListener = new MuteableSearchViewOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(final String query) {
            getFragment().onSearchQuerySubmitted(query);
            return false;
        }

        @Override
        public boolean onQueryTextChange(final String query) {
            getFragment().onSearchQueryChanged(query);
            return false;
        }
    });
    searchView.setOnQueryTextListener(onQueryTextListener);
    searchView.setOnCloseListener(() -> {
        getFragment().onSearchClosed();
        return false;
    });

    getFragment().onOptionsMenuPrepared();
    return super.onPrepareOptionsMenu(menu);
}
 
開發者ID:dmitrikudrenko,項目名稱:MDRXL,代碼行數:30,代碼來源:GeraltWomenActivity.java

示例3: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
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;
}
 
開發者ID:chengkun123,項目名稱:ReadMark,代碼行數:30,代碼來源:SearchActivity.java

示例4: initViews

import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
@Override
public void initViews(View view) {

    Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    ((SearchActivity)(getActivity())).setSupportActionBar(toolbar);
    ((SearchActivity)(getActivity())).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    searchView = (SearchView) view.findViewById(R.id.searchView);
    searchView.setIconified(false);

    recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

    progressBar = (ContentLoadingProgressBar) view.findViewById(R.id.progressBar);

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:SearchFragment.java

示例5: 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.main, menu);
    MenuItem item = menu.findItem(R.id.action_search);
    searchView = (SearchView) item.getActionView();
    if (searchView != null) {
        searchView.setQueryHint(getResources().getString(R.string.query_hint));
        searchView.setIconified(true);
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(final String query) {
                System.out.println("on search submit: " + query);
                Thread searchThread = new Thread() {
                    public void run() {
                        result.needsClear();
                        result.downloading();
                        List<Crate> crates = Networking.searchCrate(query, 1);
                        for (Crate crate : crates) {
                            result.onResult(crate);
                        }
                        searchView.post(() -> searchView.clearFocus());
                    }
                };
                searchThread.start();
                MainActivity.result.onResult(new Crate());
                return false;
            }

            @Override
            public boolean onQueryTextChange(String newText) {
                if (newText.length() > 0) {
                    if (summarySearchPager.getCurrentItem() != 1) {
                        summarySearchPager.setCurrentItem(1, true);
                    }
                }
                return false;
            }
        });
        searchView.setOnCloseListener(() -> {
            System.out.println("on search close");
            summarySearchPager.setCurrentItem(0, true);
            return false;
        });
    }
    return true;
}
 
開發者ID:TheUberCatman,項目名稱:crates-io-android,代碼行數:48,代碼來源:MainActivity.java


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