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

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

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

SearchView.setIconified介绍

暂无

代码示例

代码示例来源: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

SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setIconified(false);
searchView.clearFocus();

代码示例来源: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: bumptech/glide

@Override
public boolean onCreateOptionsMenu(Menu menu) {
 MenuInflater menuInflater = getMenuInflater();
 menuInflater.inflate(R.menu.search_activity, menu);
 searchView = (SearchView) menu.findItem(R.id.search).getActionView();
 searchView.setSubmitButtonEnabled(true);
 searchView.setIconified(false);
 searchView.setOnQueryTextListener(this);
 return true;
}

代码示例来源: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: stackoverflow.com

public void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  ActionBar actionBar = getActionBar();
  SearchView searchView = new SearchView(this);
  actionBar.setCustomView(searchView);
  actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  searchView.setQuery("test",true);
  searchView.setFocusable(true);
  searchView.setIconified(false);
  searchView.requestFocusFromTouch();
}

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

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
  searchView.setIconified(false);
  searchView.setIconifiedByDefault(false);
  searchView.clearFocus();
  }
}

代码示例来源: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

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

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

if (!Service.getInstance().hasSearchText()) {
  Log.d(MainActivity.class.getSimpleName(), "onPrepareOptionsMenu Clearing SearchView!");
  SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
  searchView.setIconified(true);// This also clears the text in SearchView widget
}

代码示例来源: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) {
  getMenuInflater().inflate(R.menu.second, menu);
  SearchView searchView =
  (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setIconified(false);
    return super.onCreateOptionsMenu(menu);
  }

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

final SearchView sv = new SearchView(((MainActivity) getActivity()).getSupportActionBar().getThemedContext());
   sv.setIconifiedByDefault(true);
   sv.setFocusable(true);
   sv.setIconified(false);
   sv.clearFocus();
   sv.requestFocusFromTouch();

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

final MenuItem searchItem = (MenuItem) menu.findItem(R.id.menu_item_search);
final SearchView searchView = (SearchView) searchItem.getActionView();

searchView.setOnQueryTextFocusChangeListener(new SearchView.OnFocusChangeListener() {
  @Override
  public void onFocusChange(View v, boolean hasFocus) {
    if (!hasFocus) {
      searchView.setIconified(true);
    }
  }
});

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

MenuItem searchMenuItem = menu.findItem(R.id.action_search);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchMenuItem.expandActionView();   searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
  searchView.setIconifiedByDefault(false);
  searchView.setFocusable(true);
  searchView.setIconified(false);
  searchView.requestFocusFromTouch();

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

@Override
 public void onCreateOptionsMenu (Menu menu, MenuInflater inflater) {
   // Inflate the menu; this adds items to the action bar if it is present.
   super.onCreateOptionsMenu(menu, inflater);
   Log.d("click" , "inside the on create");
   inflater.inflate(R.menu.main, menu);
   SearchView searchView = (SearchView) menu.findItem(R.id.menu_search2).getActionView();
   searchView.setIconified(false);
   searchView.setOnQueryTextListener(this);
 }

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

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main_activity);

  //Define your Searchview
  SearchView searchView = (SearchView) findViewById(R.id.search_bar);

  //Turn iconified to false:
  searchView.setIconified(false);
  //The above line will expand it to fit the area as well as throw up the keyboard

  //To remove the keyboard, but make sure you keep the expanded version:
  searchView.clearFocus();
}

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

public void onBackPressed() {
  //...
  SearchView searchView = ((FragmentListProduct)currentFragment).getSearchView();
  if (searchView != null) {
    if (searchView.isIconified()) {
     // the search is extended
     searchView.setIconified(true);
    } else {
     // the search view is closed
    }
  }

/...
}

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

@Override
 public void onPrepareOptionsMenu(Menu menu) {
   final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
   if(!TextUtils.isEmpty(mSearch)){
     searchView.setQuery(mSearch, false);
     searchView.setIconified(false);
     searchView.clearFocus();
   }
 }

代码示例来源:origin: TeamWalrus/Walrus

@Override
public void onBackPressed() {
  if (sv.getVisibility() != View.GONE) {
    sv.setIconified(true);
    sv.setVisibility(View.GONE);
  } else {
    super.onBackPressed();
  }
}

相关文章