android.widget.SearchView.setQueryHint()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中android.widget.SearchView.setQueryHint()方法的一些代码示例,展示了SearchView.setQueryHint()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SearchView.setQueryHint()方法的具体详情如下:
包路径:android.widget.SearchView
类名称:SearchView
方法名:setQueryHint

SearchView.setQueryHint介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setQueryHint("Query Hint");

代码示例来源:origin: k9mail/k-9

private void configureFolderSearchView(Menu menu) {
  final MenuItem folderMenuItem = menu.findItem(R.id.filter_folders);
  final SearchView folderSearchView = (SearchView) folderMenuItem.getActionView();
  folderSearchView.setQueryHint(getString(R.string.folder_list_filter_hint));
  folderSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
    @Override
    public boolean onQueryTextSubmit(String query) {
      folderMenuItem.collapseActionView();
      return true;
    }
    @Override
    public boolean onQueryTextChange(String newText) {
      mAdapter.getFilter().filter(newText);
      return true;
    }
  });
}

代码示例来源:origin: stackoverflow.com

private void setupSearchView(SearchView searchView)
{
  // search hint
  searchView.setQueryHint(getString(R.string.fragment_address_search_hint));

  // background
  View searchPlate = searchView.findViewById(android.support.v7.appcompat.R.id.search_plate);
  searchPlate.setBackgroundResource(R.drawable.searchview_bg);

  // icon
  ImageView searchIcon = (ImageView) searchView.findViewById(android.support.v7.appcompat.R.id.search_mag_icon);
  searchIcon.setImageResource(R.drawable.searchview_icon);

  // clear button
  ImageView searchClose = (ImageView) searchView.findViewById(android.support.v7.appcompat.R.id.search_close_btn);
  searchClose.setImageResource(R.drawable.searchview_clear);

  // text color
  AutoCompleteTextView searchText = (AutoCompleteTextView) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
  searchText.setTextColor(getResources().getColor(R.color.global_text_primary));
  searchText.setHintTextColor(getResources().getColor(R.color.global_text_secondary));
}

代码示例来源:origin: k9mail/k-9

private void configureFolderSearchView(Menu menu) {
  final MenuItem folderMenuItem = menu.findItem(R.id.filter_folders);
  final SearchView folderSearchView = (SearchView) folderMenuItem.getActionView();
  folderSearchView.setQueryHint(getString(R.string.folder_list_filter_hint));
  folderSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
    @Override
    public boolean onQueryTextSubmit(String query) {
      folderMenuItem.collapseActionView();
      actionBar.setTitle(R.string.filter_folders_action);
      return true;
    }
    @Override
    public boolean onQueryTextChange(String newText) {
      adapter.getFilter().filter(newText);
      return true;
    }
  });
  folderSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
    @Override
    public boolean onClose() {
      actionBar.setTitle(R.string.folders_title);
      return false;
    }
  });
}

代码示例来源:origin: stackoverflow.com

mSearchView.setOnQueryTextListener(this);
mSearchView.setSubmitButtonEnabled(true);
mSearchView.setQueryHint("Search Here");

代码示例来源:origin: stackoverflow.com

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

  //Create the search view
  SearchView searchView = new SearchView(getSherlockActivity().getSupportActionBar().getThemedContext());
  searchView.setQueryHint("Search for countries…");
  searchView.setIconified(false);

  menu.add("Search")
      .setIcon(R.drawable.abs__ic_search)
      .setActionView(searchView)
      .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the options menu from XML
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.your_menu, menu);

  // Get the SearchView and set the searchable configuration
  SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
  SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
  searchView.setOnQueryTextListener(this);
  // Assumes current activity is the searchable activity
  SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName());

  // DO THIS BEFORE setSearchableInfo !!!
  searchView.setQueryHint(null);

  searchView.setSearchableInfo(searchableInfo);

  return true;
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the options menu from XML
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.your_menu, menu);

  // Get the SearchView and set the searchable configuration
  SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
  SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
  searchView.setOnQueryTextListener(this);
  // Assumes current activity is the searchable activity
  SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName());
  searchView.setSearchableInfo(searchableInfo);

  // Override the hint with whatever you like
  searchView.setQueryHint(getResources().getString(R.strings.your_hint));

  return true;
}

代码示例来源:origin: stackoverflow.com

SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
searchView.setQueryHint("some text");

smenu=menu.add("smenu").setVisible(false).setActionView(searchView);
smenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

代码示例来源:origin: stackoverflow.com

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) 
{
  super.onCreateOptionsMenu(menu, inflater);

  inflater.inflate(R.menu.menu, menu);
  final MenuItem searchItem = menu.findItem(R.id.menu_item_search);
  final SearchView searchView = (SearchView) searchItem.getActionView();
  searchView.setQueryHint("Search Here");
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.global_search, menu);

  final MenuItem item = menu.findItem(R.id.action_search);

  MenuItemCompat.expandActionView(item);

  final SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);

  searchView.setQueryHint(getString(R.string.search_customers));

  searchView.setOnQueryTextListener(this);

  return true;
}

代码示例来源:origin: stackoverflow.com

final SearchView searchView = (SearchView) itemSearch.getActionView();
 searchView.setQueryHint(Html
     .fromHtml("<font color = #ffffff>Search...</font>"));
 searchView.setOnSearchClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {
     //your code
   }
 });

代码示例来源:origin: stackoverflow.com

@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_home, menu);
  SearchView search = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.action_search);
  // Associate searchable configuration with the SearchView
  SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
  search.setSearchableInfo(searchManager.getSearchableInfo(new ComponentName(this, SearchResultsActivity.class)));
  search.setQueryHint(getResources().getString(R.string.search_hint));
  return true;
}

代码示例来源:origin: stackoverflow.com

SearchView searchView = (SearchView)mLayout.findViewById(R.id.m_searchview);
searchView.setQueryHint("search for something");
View searchTextView = searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
searchTextView.setBackground(
ResourcesCompat.getDrawable(getResources(), R.drawable. rounded_corner_box, getTheme()));
View searchFrame = searchView.findViewById(android.support.v7.appcompat.R.id.search_edit_frame);
searchFrame.setBackground(ResourcesCompat.getDrawable(getResources(), R.drawable.m_background, getTheme()));

代码示例来源:origin: stackoverflow.com

SearchView searchView = new SearchView(canvas.getContext());
searchView.setQueryHint("Type your text here");
searchView.setBackgroundColor(Color.WHITE);

OptionCommand searchCommand = new OptionCommand();
searchCommand.setActionView(searchView);
searchCommand.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

代码示例来源:origin: stackoverflow.com

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  MenuItem searchItem = menu.findItem(R.id.action_search);
  SearchView searchview = (SearchView) MenuItemCompat.getActionView(searchItem);
  searchview.setIconifiedByDefault(true);
  searchview.setOnQueryTextListener(this);
  searchview.setSubmitButtonEnabled(true);  
  searchview.setQueryHint("Search Here"); 
  super.onCreateOptionsMenu(menu, inflater);
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.core_actions, 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(false);
  searchView.setQueryHint(getString(R.string.search_hint));

  searchView.setOnQueryTextListener(this);

  return true;
}

代码示例来源:origin: li2/learning-android-open-source

private void setupSearchView() {
  mSearchView.setIconifiedByDefault(false);
  mSearchView.setOnQueryTextListener(this);
  mSearchView.setSubmitButtonEnabled(false);
  mSearchView.setQueryHint(getString(R.string.cheese_hunt_hint));
}

代码示例来源:origin: stackoverflow.com

private SearchView getSearchView() {
  SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
  SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
  searchView.setQueryHint("Search for items");
  searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

  AutoCompleteTextView searchTextView =
      (AutoCompleteTextView) searchView.findViewById(R.id.abs__search_src_text);
  if (searchTextView != null) {
    searchTextView.setInputType(InputType.TYPE_CLASS_TEXT
                  | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
    searchTextView.setTypeface(Typeface.DEFAULT);
  }
  return searchView;
}

代码示例来源:origin: qiubiteme/android_api_demos

private void setupSearchView() {
  mSearchView.setIconifiedByDefault(false);
  mSearchView.setOnQueryTextListener(this);
  mSearchView.setSubmitButtonEnabled(false);
  mSearchView.setQueryHint(getString(R.string.cheese_hunt_hint));
}

相关文章