本文整理汇总了Java中android.support.v7.widget.SearchView.setMaxWidth方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.setMaxWidth方法的具体用法?Java SearchView.setMaxWidth怎么用?Java SearchView.setMaxWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.SearchView
的用法示例。
在下文中一共展示了SearchView.setMaxWidth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if(loaderId == DELETED_LOADER_ID){
inflater.inflate(R.menu.menu_fragment_bin, menu);
}
// Place an action bar item for searching.
MenuItem item = menu.add("Search");
item.setIcon(R.drawable.ic_search_white_24dp);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM|MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
searchView = new SearchView(myActivity);
searchView.setMaxWidth(Integer.MAX_VALUE);
// Set searchbox text to white
EditText searchEditText = (EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
searchEditText.setTextColor(ContextCompat.getColor(getContext(), R.color.white));
searchEditText.setHintTextColor(ContextCompat.getColor(getContext(), R.color.white));
searchView.setOnQueryTextListener(this);
item.setActionView(searchView);
super.onCreateOptionsMenu(menu, inflater);
}
示例3: 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);
}
示例4: onCreateActionMode
import android.support.v7.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
// mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search_menu));
mSearchView = new SearchView(getSupportActionBar().getThemedContext());
ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT);
mSearchView.setLayoutParams(params);
mSearchView.setLayoutParams(new ActionBar.LayoutParams(Gravity.LEFT));
mSearchView.setMaxWidth(Integer.MAX_VALUE);
// mSearchView = new SearchView();
setupSearchView(mSearchView);
// search menu item
MenuItem searchMenuItem = menu.add(Menu.NONE, Menu.NONE, 2, getString(R.string.menu_search));
searchMenuItem.setIcon(R.drawable.search);
searchMenuItem.expandActionView();
MenuItemCompat.setActionView(searchMenuItem, mSearchView);
MenuItemCompat.setShowAsAction(searchMenuItem, MenuItem.SHOW_AS_ACTION_ALWAYS);
MenuItem searchMenuItem3 = menu.add(Menu.NONE, Menu.NONE, 1, getString(R.string.menu_search));
searchMenuItem3.setIcon(R.drawable.search);
MenuItemCompat.setActionView(searchMenuItem3, iv);
MenuItemCompat.setShowAsAction(searchMenuItem3, MenuItem.SHOW_AS_ACTION_ALWAYS);
return true;
}