当前位置: 首页>>代码示例>>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;未经允许,请勿转载。