本文整理汇总了Java中android.widget.SearchView.setQuery方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.setQuery方法的具体用法?Java SearchView.setQuery怎么用?Java SearchView.setQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.SearchView
的用法示例。
在下文中一共展示了SearchView.setQuery方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onResume
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
List<File> containers = FileUtils.getContainers(getActivity());
final ContainerListAdapter containerListAdapter = new ContainerListAdapter(getActivity(), containers);
setListAdapter(containerListAdapter);
SearchView searchView = (SearchView) getActivity().findViewById(R.id.listSearch);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
containerListAdapter.getFilter().filter(newText);
return false;
}
});
searchView.setQuery("", false);
getActivity().findViewById(R.id.content_browse_containers).requestFocus();
}
示例2: onFocusChange
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onFocusChange(View view, boolean hasFocus) {
if(!(view instanceof SearchView)){
return;
}
mIsExpand = hasFocus;
SearchView searchView = (SearchView)view;
ViewGroup.LayoutParams lp = searchView.getLayoutParams();
if(lp != null){
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
}
searchView.setQuery(mSearchText, false);
}
示例3: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.searchview_in_menu, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
mSearchView = (SearchView) searchItem.getActionView();
setupSearchView(searchItem);
if (mQuery != null) {
mSearchView.setQuery(mQuery, false);
}
return true;
}
示例4: onPrepareOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onPrepareOptionsMenu(Menu menu) {
final MenuItem searchItem = menu.findItem(R.id.action_lookup);
searchView = (SearchView)searchItem.getActionView();
searchView.setOnQueryTextListener(this);
if(openSearch){
searchView.setIconified(false);
searchView.setQuery(textQuery,false);
searchView.requestFocus();
}
}
示例5: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.vk_search_menu, menu);
MenuItem menuItem = menu.findItem(R.id.vk_search);
menuItem.setOnActionExpandListener(this);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuItem);
searchView.setOnQueryTextListener(this);
searchView.setOnQueryTextFocusChangeListener(this);
searchView.setQuery(mSearchText, false);
searchView.setIconifiedByDefault(false);
}
示例6: makeSearchMenuEntry
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public MenuItem makeSearchMenuEntry(Menu menu) {
MenuItem item = menu.add("Search");
searchView = new SearchView(diskusage);
origSearchBackground = searchView.getBackground();
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
item.setIcon(android.R.drawable.ic_search_category_default);
item.setActionView(searchView);
if (searchPattern != null) {
searchView.setIconified(false);
searchView.setQuery(searchPattern, false);
}
searchView.setOnCloseListener(new OnCloseListener() {
@Override
public boolean onClose() {
Log.d("diskusage", "search closed");
searchPattern = null;
diskusage.applyPatternNewRoot(masterRoot, null);
return false;
}
});
searchView.setOnQueryTextListener(new OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
onQueryTextChange(query);
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
Log.d("diskusage", "search query changed to: " + newText);
searchPattern = newText;
applyPattern(searchPattern);
return true;
}
});
return item;
}
示例7: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_add_remove_fragment, menu);
// Setup SearchView
SearchManager searchManager = (SearchManager)getActivity().getSystemService(Context.SEARCH_SERVICE);
MenuItem searchItem = menu.findItem(R.id.search);
searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
networkRecyclerAdapter.getFilter().filter(newText);
return true;
}
});
// Recreate the last search if the screen was rotated
if(last_filter_term != null && last_filter_term.length() > 0){
searchView.setQuery(last_filter_term, true);
searchView.setIconified(false);
searchView.clearFocus();
}
}
示例8: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_manage_poi, menu);
final MenuItem searchItem = menu.findItem(R.id.action_search);
searchView = (SearchView) searchItem.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
onQueryTextChange(query);
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
typesAdapter.getFilter().filter(newText);
filterConstraint = newText;
return true;
}
});
if (!showingTypes) {
searchView.setVisibility(View.GONE);
}
if (showingTypes && !StringUtils.isEmpty(filterConstraint)) {
searchView.setIconified(false);
searchView.setQuery(filterConstraint, true);
}
return true;
}
示例9: query
import android.widget.SearchView; //导入方法依赖的package包/类
/**
* An action which sets the query property of {@code view} with character sequences.
* <p>
* <em>Warning:</em> The created observable keeps a strong reference to {@code view}. Unsubscribe
* to free this reference.
*
* @param submit whether to submit query right after updating query text
*/
@CheckResult @NonNull
public static Consumer<? super CharSequence> query(@NonNull final SearchView view,
final boolean submit) {
checkNotNull(view, "view == null");
return new Consumer<CharSequence>() {
@Override public void accept(CharSequence text) {
view.setQuery(text, submit);
}
};
}
示例10: onCreateOptionsMenu
import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
{
super.onCreateOptionsMenu(menu,inflater);
inflater.inflate(R.menu.contact_list_menu, menu);
MenuItem searchItem = menu.findItem(R.id.menu_search);
final SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
final SearchView searchView = (SearchView) searchItem.getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setOnQueryTextListener(
new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
String newFilter = !TextUtils.isEmpty(newText) ? newText : null;
if (mSearchTerm == null && newFilter == null) {
return true;
}
if (mSearchTerm != null && mSearchTerm.equals(newFilter)) {
return true;
}
mSearchTerm = newFilter;
mSearchQueryChanged = true;
getLoaderManager().restartLoader(ContactsQuery.QUERY_ID, null, ContactsFragment.this);
return true;
}
}
);
if (mSearchTerm != null)
{
final String savedSearchTerm = mSearchTerm;
searchItem.expandActionView();
searchView.setQuery(savedSearchTerm, false);
}
}