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

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

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

SearchView.setIconifiedByDefault介绍

暂无

代码示例

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.my_activity, menu);

  MenuItem searchViewItem = menu.findItem(R.id.menu_search);
  SearchView searchView = (SearchView) searchViewItem.getActionView();
  [...]
  searchView.setIconifiedByDefault(false);

  return true;
}

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

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

  SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
  SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
  // Tells your app's SearchView to use this activity's searchable configuration
  searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
  searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default

  return true;
}

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

public boolean onCreateOptionsMenu(Menu menu) {
   super.onCreateOptionsMenu(menu);
   MenuInflater inflater = getMenuInflater();
   inflater.inflate(R.menu.action_bar, menu);
   MenuItem searchItem = menu.findItem(R.id.menu_item_search);
   SearchView searchView = (SearchView) searchItem.getActionView();
   SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
   if(null!=searchManager ) {   
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
   }
   searchView.setIconifiedByDefault(false);
   return true;
 }

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

SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
 searchView.setIconifiedByDefault(true);
 searchView.setFocusable(true);
 searchView.setIconified(false);
 searchView.requestFocusFromTouch();

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getSupportMenuInflater().inflate(R.menu.main, menu);

  SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
  SearchView searchView = (SearchView) menu.findItem(R.id.menu_search)
      .getActionView();
  if (null != searchView) {
    searchView.setSearchableInfo(searchManager
        .getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);
  }

  SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
    public boolean onQueryTextChange(String newText) {
      // this is your adapter that will be filtered
      return true;
    }

    public boolean onQueryTextSubmit(String query) {
      //Here u can get the value "query" which is entered in the search box.

    }
  };
  searchView.setOnQueryTextListener(queryTextListener);

  return super.onCreateOptionsMenu(menu);
}

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

searchView.setIconifiedByDefault(false);

代码示例来源:origin: commonsguy/cw-omnibus

private void configureSearchView(Menu menu) {
 MenuItem search=menu.findItem(R.id.search);
 search.setOnActionExpandListener(this);
 sv=(SearchView)search.getActionView();
 sv.setOnQueryTextListener(this);
 sv.setSubmitButtonEnabled(true);
 sv.setIconifiedByDefault(true);
 if (initialQuery != null) {
  sv.setIconified(false);
  search.expandActionView();
  sv.setQuery(initialQuery, true);
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

private void configureSearchView(Menu menu) {
 MenuItem search=menu.findItem(R.id.search);
 sv=(SearchView)search.getActionView();
 sv.setOnQueryTextListener(this);
 sv.setOnCloseListener(this);
 sv.setSubmitButtonEnabled(false);
 sv.setIconifiedByDefault(true);
 if (initialQuery != null) {
  sv.setIconified(false);
  search.expandActionView();
  sv.setQuery(initialQuery, true);
 }
}

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

mSearchView.setIconifiedByDefault(false);
mSearchView.setOnQueryTextListener(this);
mSearchView.setSubmitButtonEnabled(true);

代码示例来源:origin: robolectric/robolectric

@Test
public void canGetOptionsMenuWithActionMenu() throws Exception {
 ActionMenuActivity activity = buildActivity(ActionMenuActivity.class).create().visible().get();
 SearchView searchView = activity.mSearchView;
 // This blows up when ShadowPopupMenu existed.
 searchView.setIconifiedByDefault(false);
}

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

searchView.setIconifiedByDefault(false);

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

MenuItemCompat.setActionView(item, sv);
sv.setOnQueryTextListener(this);
sv.setIconifiedByDefault(false);
sv.setOnSearchClickListener(new View.OnClickListener() {
  @Override

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

MenuItemCompat.setActionView(item, searchview);
searchview.setOnQueryTextListener(this);
searchview.setIconifiedByDefault(false);

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

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

  MenuItem searchMenuItem = menu.findItem(R.id.activity_home_action_search);

  SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
  searchView.setIconifiedByDefault(true);
}

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

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
  searchView.setIconifiedByDefault(false);
  getActionBar().setCustomView(searchView);
  getActionBar().setDisplayShowCustomEnabled(true);
}

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

MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_search, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);

SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search));
searchView.setSearchableInfo(searchManager.getSearchableInfo(new ComponentName(getApplicationContext(), SearchActivity.class)));
searchView.setMaxWidth(Integer.MAX_VALUE);
MenuItemCompat.expandActionView(menu.findItem(R.id.search));
searchView.setIconifiedByDefault(true);
searchView.setIconified(false);

代码示例来源: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: commonsguy/cw-androidarch

private void configureSearchView(Menu menu) {
 MenuItem search=menu.findItem(R.id.search);
 sv=(SearchView)search.getActionView();
 sv.setOnQueryTextListener(this);
 sv.setOnCloseListener(this);
 sv.setSubmitButtonEnabled(true);
 sv.setIconifiedByDefault(true);
}

代码示例来源:origin: maks/MGit

public void configSearchAction(MenuItem searchItem) {
  SearchView searchView = (SearchView) searchItem.getActionView();
  if (searchView == null)
    return;
  SearchListener searchListener = new SearchListener();
  MenuItemCompat.setOnActionExpandListener(searchItem, searchListener);
  searchView.setIconifiedByDefault(true);
  searchView.setOnQueryTextListener(searchListener);
}

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

@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  // Place an action bar item for searching.
  MenuItem item = menu.add("Search");
  item.setIcon(android.R.drawable.ic_menu_search);
  item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
      | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
  mSearchView = new MySearchView(getActivity());
  mSearchView.setOnQueryTextListener(this);
  mSearchView.setOnCloseListener(this);
  mSearchView.setIconifiedByDefault(true);
  item.setActionView(mSearchView);
}

相关文章