本文整理了Java中android.support.v7.widget.SearchView.setIconifiedByDefault()
方法的一些代码示例,展示了SearchView.setIconifiedByDefault()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SearchView.setIconifiedByDefault()
方法的具体详情如下:
包路径:android.support.v7.widget.SearchView
类名称:SearchView
方法名:setIconifiedByDefault
暂无
代码示例来源:origin: jgilfelt/chuck
@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);
}
代码示例来源:origin: aa112901/remusic
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
mSearchView.setOnQueryTextListener(this);
mSearchView.setQueryHint(getResources().getString(R.string.search_local_music));
mSearchView.setIconifiedByDefault(false);
mSearchView.setIconified(false);
MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.menu_search), new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
finish();
return false;
}
});
menu.findItem(R.id.menu_search).expandActionView();
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: aa112901/remusic
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
mSearchView.setOnQueryTextListener(this);
mSearchView.setQueryHint(getResources().getString(R.string.search_net_music));
mSearchView.setIconifiedByDefault(false);
mSearchView.setIconified(false);
MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.menu_search), new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
finish();
return false;
}
});
menu.findItem(R.id.menu_search).expandActionView();
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: naman14/Timber
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
mSearchView.setOnQueryTextListener(this);
mSearchView.setQueryHint(getString(R.string.search_library));
mSearchView.setIconifiedByDefault(false);
mSearchView.setIconified(false);
MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.menu_search), new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
finish();
return false;
}
});
menu.findItem(R.id.menu_search).expandActionView();
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setFocusable(false);
searchView.setIconifiedByDefault(true);
searchView.setMaxWidth(Integer.MAX_VALUE);
searchView.setQueryHint("请输入URL关键字...");
代码示例来源:origin: algolia/instantsearch-android
/**
* Sets the default or resting state of the search field. If {@code true}, a single search icon is
* shown by default and expands to show the text field and other buttons when pressed. Also,
* if the default state is iconified, then it collapses to that state when the close button
* is pressed. Changes to this property will take effect immediately.
* <p>The default value is true.</p>
*
* @param iconified whether the search field should be iconified by default
*/
public void setIconifiedByDefault(boolean iconified) {
if (searchView != null) {
searchView.setIconifiedByDefault(iconified);
} else if (supportView != null) {
supportView.setIconifiedByDefault(iconified);
} else {
throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
}
}
代码示例来源:origin: Odoo-mobile/framework
public void setHasSearchView(IOnSearchViewChangeListener listener,
Menu menu, int menu_id) {
mOnSearchViewChangeListener = listener;
mSearchView = (SearchView) MenuItemCompat.getActionView(menu
.findItem(menu_id));
if (mSearchView != null) {
mSearchView.setOnCloseListener(closeListener);
mSearchView.setOnQueryTextListener(searchViewQueryListener);
mSearchView.setIconifiedByDefault(true);
}
}
代码示例来源:origin: Exodus-Privacy/exodus-android-app
@Override
public boolean onCreateOptionsMenu(Menu menu) {
mMenu = menu;
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
searchView = (SearchView) menu.findItem(R.id.action_filter).getActionView();
searchView.setIconifiedByDefault(false);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
appList.filter(query);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
appList.filter(newText);
return true;
}
});
return true;
}
}
代码示例来源:origin: w568w/fuckView
@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);
}
代码示例来源:origin: a-voyager/WeekToDo
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setIconifiedByDefault(true);
return true;
}
代码示例来源:origin: retomeier/Wrox-ProfessionalAndroid-4E
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
// Inflate the options menu from XML
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
// Use the Search Manager to find the SearchableInfo related
// to the Search Result Activity.
SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchableInfo searchableInfo = searchManager.getSearchableInfo(
new ComponentName(getApplicationContext(),
EarthquakeSearchResultActivity.class));
SearchView searchView =
(SearchView)menu.findItem(R.id.search_view).getActionView();
searchView.setSearchableInfo(searchableInfo);
searchView.setIconifiedByDefault(false);
return true;
}
代码示例来源:origin: rohanoid5/Muzesto
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
mSearchView.setOnQueryTextListener(this);
mSearchView.setQueryHint(getString(R.string.search_library));
mSearchView.setIconifiedByDefault(false);
mSearchView.setIconified(false);
MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.menu_search), new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
finish();
return false;
}
});
menu.findItem(R.id.menu_search).expandActionView();
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: retomeier/Wrox-ProfessionalAndroid-4E
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the options menu from XML
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main, menu);
// Use the Search Manager to find the SearchableInfo related
// to this Activity.
SearchManager searchManager =
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchableInfo searchableInfo =
searchManager.getSearchableInfo(getComponentName());
SearchView searchView =
(SearchView) menu.findItem(R.id.search_view).getActionView();
searchView.setSearchableInfo(searchableInfo);
searchView.setIconifiedByDefault(false);
return true;
}
}
代码示例来源:origin: brainysoon/cyberCar
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
mSearchView.setOnQueryTextListener(this);
mSearchView.setQueryHint(getString(R.string.search_library));
mSearchView.setIconifiedByDefault(false);
mSearchView.setIconified(false);
MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.menu_search), new MenuItemCompat.OnActionExpandListener() {
@Override
public boolean onMenuItemActionExpand(MenuItem item) {
return true;
}
@Override
public boolean onMenuItemActionCollapse(MenuItem item) {
finish();
return false;
}
});
menu.findItem(R.id.menu_search).expandActionView();
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: AppLozic/Applozic-Android-SDK
@SuppressLint("NewApi")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
showActionBar();
//return false;
getMenuInflater().inflate(R.menu.mobicom_basic_menu_for_normal_message, menu);
MenuItem searchItem = menu.findItem(R.id.menu_search);
searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setQueryHint(getResources().getString(R.string.search_hint));
if (Utils.hasICS()) {
searchItem.collapseActionView();
}
searchView.setOnQueryTextListener(this);
searchView.setSubmitButtonEnabled(true);
searchView.setIconifiedByDefault(true);
if (quickConversationFragment != null && !TextUtils.isEmpty(quickConversationFragment.getSearchString())) {
searchView.setIconified(false);
searchView.setQuery(quickConversationFragment.getSearchString(), false);
}
return super.onCreateOptionsMenu(menu);
}
代码示例来源:origin: 0xZhangKe/ShiZhong
private void setupSearchView(final SearchView searchView) {
searchView.setIconified(true);
searchView.setIconifiedByDefault(false);
searchView.setSubmitButtonEnabled(true);
searchView.setFocusable(true);
searchView.requestFocusFromTouch();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
curQueryText = newText;
search();
return true;
}
});
}
代码示例来源:origin: garretyoder/app-theme-engine
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_collapsingtoolbar);
final CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsingToolbar);
collapsingToolbar.setTitle(getTitle());
collapsingToolbar.setExpandedTitleColor(Config.textColorPrimaryInverse(this, getATEKey()));
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setNavigationIcon(R.drawable.ic_back);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
toolbar.inflateMenu(R.menu.main);
final Menu menu = toolbar.getMenu();
final MenuItem searchItem = menu.findItem(R.id.search);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setQueryHint(getString(R.string.search_view_example));
searchView.setIconifiedByDefault(true);
}
}
代码示例来源:origin: anitaa1990/TrailersApp
private void initialiseView() {
binding = DataBindingUtil.setContentView(this, R.layout.activity_search);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
binding.search.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
binding.search.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
binding.search.setIconifiedByDefault(false);
binding.search.setOnQueryTextListener(this);
EditText searchEditText = binding.search.findViewById(android.support.v7.appcompat.R.id.search_src_text);
searchEditText.setTextColor(getResources().getColor(android.R.color.white));
searchEditText.setHintTextColor(getResources().getColor(android.R.color.white));
Typeface myCustomFont = ResourcesCompat.getFont(getApplicationContext(), R.font.gt_medium);
searchEditText.setTypeface(myCustomFont);
searchListAdapter = new MovieSearchListAdapter(this);
binding.includedLayout.moviesList.setLayoutManager(new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL, false));
binding.includedLayout.moviesList.setAdapter(searchListAdapter);
SnapHelper startSnapHelper = new PagerSnapHelper(position -> {
MovieEntity trailer = searchListAdapter.getItem(position);
updateBackground(trailer.getPosterPath());
});
startSnapHelper.attachToRecyclerView(binding.includedLayout.moviesList);
binding.includedLayout.moviesList.addOnItemTouchListener(new RecyclerItemClickListener(getApplicationContext(), this));
}
代码示例来源:origin: anitaa1990/TrailersApp
private void initialiseView() {
binding = DataBindingUtil.setContentView(this, R.layout.activity_search);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
binding.search.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
binding.search.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
binding.search.setIconifiedByDefault(false);
binding.search.setOnQueryTextListener(this);
EditText searchEditText = binding.search.findViewById(android.support.v7.appcompat.R.id.search_src_text);
searchEditText.setTextColor(getResources().getColor(android.R.color.white));
searchEditText.setHintTextColor(getResources().getColor(android.R.color.white));
Typeface myCustomFont = ResourcesCompat.getFont(getApplicationContext(), R.font.gt_medium);
searchEditText.setTypeface(myCustomFont);
searchListAdapter = new TvSearchListAdapter(this);
binding.includedLayout.moviesList.setLayoutManager(new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL, false));
binding.includedLayout.moviesList.setAdapter(searchListAdapter);
SnapHelper startSnapHelper = new PagerSnapHelper(position -> {
TvEntity trailer = searchListAdapter.getItem(position);
updateBackground(trailer.getPosterPath());
});
startSnapHelper.attachToRecyclerView(binding.includedLayout.moviesList);
binding.includedLayout.moviesList.addOnItemTouchListener(new RecyclerItemClickListener(getApplicationContext(), this));
}
代码示例来源:origin: CooLoongWu/CoolChat
private void initViews() {
layout_points = (LinearLayout) findViewById(R.id.layout_points);
SearchView searchView = (SearchView) findViewById(R.id.search_view);
//设置显示提交按钮
searchView.setSubmitButtonEnabled(true);
//一开始就处于显示SearchView的状态
searchView.setIconifiedByDefault(false);
//设置一开始就显示输入框
searchView.setIconified(true);
searchView.clearFocus();
SearchView.SearchAutoComplete editText = (SearchView.SearchAutoComplete) searchView.findViewById(R.id.search_src_text);
editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
searchFriend(query.trim());
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (!newText.isEmpty()) {
searchFriend(newText);
}
return false;
}
});
}
内容来源于网络,如有侵权,请联系作者删除!