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