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


Java SearchView.setIconifiedByDefault方法代码示例

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


在下文中一共展示了SearchView.setIconifiedByDefault方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    final MenuItem item = menu.findItem(R.id.action_search);
    SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(item);
    mSearchView.setIconifiedByDefault(true);
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            if (shouldShowFAQ)
                ((Searchable) currentFragment).setSearchText(newText);
            return true;
        }
    });
    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:w568w,项目名称:fuckView,代码行数:22,代码来源:MainActivity.java

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

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

示例5: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.menu_search, menu);
    MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setQueryHint(getString(R.string.search_hint));
    searchView.setIconifiedByDefault(false);
    ImageView search_mag_icon = (ImageView) searchView.findViewById(R.id.search_mag_icon);
    search_mag_icon.setImageResource(0);
    LinearLayout search_plate = (LinearLayout) searchView.findViewById(R.id.search_plate);
    search_plate.setBackgroundColor(Color.TRANSPARENT);
    searchView.setOnQueryTextListener(mQueryListener);
}
 
开发者ID:XYScience,项目名称:StopApp,代码行数:15,代码来源:AppListFragment.java

示例6: 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.menu_main, menu);
    MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setQueryHint(getString(R.string.search_hint));
    searchView.setIconifiedByDefault(false);
    ImageView search_mag_icon = (ImageView) searchView.findViewById(R.id.search_mag_icon);
    search_mag_icon.setImageResource(0);
    LinearLayout search_plate = (LinearLayout) searchView.findViewById(R.id.search_plate);
    search_plate.setBackgroundColor(Color.TRANSPARENT);
    searchView.setOnQueryTextListener(mQueryListener);
    return true;
}
 
开发者ID:XYScience,项目名称:StopApp,代码行数:16,代码来源:MainActivity.java

示例7: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_select_file, menu);
    mSearchViewMenuItem = menu.findItem(R.id.im_search);
    mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchViewMenuItem);
    mSearchView.setIconifiedByDefault(true);
    mSearchView.setOnQueryTextListener(this);
    mSearchView.setSubmitButtonEnabled(false);
    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:ujjwalagrawal17,项目名称:CodeCompilerApp,代码行数:11,代码来源:SelectFileActivity.java

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

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

示例10: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.chuck_main, menu);
    MenuItem searchMenuItem = menu.findItem(R.id.search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setOnQueryTextListener(this);
    searchView.setIconifiedByDefault(true);
    super.onCreateOptionsMenu(menu, inflater);
}
 
开发者ID:jgilfelt,项目名称:chuck,代码行数:10,代码来源:TransactionListFragment.java

示例11: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
            getMenuInflater().inflate(R.menu.white_list_activity_menu, menu);
            SearchManager searchManager =
                    (SearchManager) getSystemService(Context.SEARCH_SERVICE);
            final SearchView searchView = (SearchView) menu.findItem(R.id.ab_search).getActionView();

            selectAll=menu.findItem(R.id.select_all);
            setSelection=menu.findItem(R.id.setSelection);

            final SearchView.SearchAutoComplete searchEditText = (SearchView.SearchAutoComplete) searchView.findViewById(R.id.search_src_text);

            searchEditText.setTextColor(getResources().getColor(R.color.white));
            searchView.setQueryHint("Search");

            // 将搜索按钮放到搜索输入框的外边
            searchView.setIconifiedByDefault(false);


            searchView.setSearchableInfo(
                    searchManager.getSearchableInfo(getComponentName()));
            searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
                @Override
                public boolean onQueryTextSubmit(String query) {
                    return false;
                }

                @Override
                public boolean onQueryTextChange(String newText) {
                    refreshListByQuery(searchView.getQuery().toString());
                    return true;
                }
            });
            searchView.setOnCloseListener(new SearchView.OnCloseListener() {
                @Override
                public boolean onClose() {
                    refreshListByQuery("");
                    return false;
                }
            });

//            MenuItem menuItem=menu.add("恢复默认");
//            menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
//            menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
//                @Override
//                public boolean onMenuItemClick(MenuItem item) {
//                    if(mSelectedApplicationInfos==null){
//                        SnackBarUtil.show(toolbar,R.string.wait_until_loaded);
//                        return true;
//                    }
//                    for (AppListAdapter.ApplicationInfoWrap app:mSelectedApplicationInfos){
//                        app.isSelected=false;
//                    }
//                    mSelectedApplicationInfos.clear();
//                    mAppAdapter.notifyDataSetChanged();
//                    refreshTV();
//                    return true;
//                }
//            });
        }
        refreshMenu(false);
        return true;
    }
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:65,代码来源:FloatViewWhiteListActivity.java

示例12: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
            getMenuInflater().inflate(R.menu.white_list_activity_menu, menu);
            SearchManager searchManager =
                    (SearchManager) getSystemService(Context.SEARCH_SERVICE);
            final SearchView searchView = (SearchView) menu.findItem(R.id.ab_search).getActionView();

            selectAll=menu.findItem(R.id.select_all);
            setSelection=menu.findItem(R.id.setSelection);

            final SearchView.SearchAutoComplete searchEditText = (SearchView.SearchAutoComplete) searchView.findViewById(R.id.search_src_text);

            searchEditText.setTextColor(getResources().getColor(R.color.white));
            searchView.setQueryHint("Search");

            // 将搜索按钮放到搜索输入框的外边
            searchView.setIconifiedByDefault(false);


            searchView.setSearchableInfo(
                    searchManager.getSearchableInfo(getComponentName()));
            searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
                @Override
                public boolean onQueryTextSubmit(String query) {
                    return false;
                }

                @Override
                public boolean onQueryTextChange(String newText) {
                    refreshListByQuery(searchView.getQuery().toString());
                    return true;
                }
            });
            searchView.setOnCloseListener(new SearchView.OnCloseListener() {
                @Override
                public boolean onClose() {
                    refreshListByQuery("");
                    return false;
                }
            });

//            MenuItem menuItem=menu.add("恢复默认");
//            menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
//            menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
//                @Override
//                public boolean onMenuItemClick(MenuItem item) {
//                    if(mSelectedApplicationInfos==null){
//                        SnackBarUtil.show(toolbar,R.string.wait_until_loaded);
//                        return true;
//                    }
//                    for (AppListAdapter.ApplicationInfoWrap app:mSelectedApplicationInfos){
//                        app.isSelected=false;
//                    }
//                    mSelectedApplicationInfos.clear();
//                    mAppAdapter.notifyDataSetChanged();
//                    refreshTV();
//                    return true;
//                }
//            });
        }
        setSelection.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                showPopupMenu(toolbar);
                return true;
            }
        });
        refreshMenu(false);
        return true;
    }
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:72,代码来源:WhiteListActivity.java


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