本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}