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

x33g5p2x  于2022-01-29 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(155)

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

SearchView.setIconified介绍

暂无

代码示例

代码示例来源:origin: aa112901/remusic

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
  getMenuInflater().inflate(R.menu.menu_search, menu);
  mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
  mSearchView.setOnQueryTextListener(this);
  mSearchView.setQueryHint(getResources().getString(R.string.search_net_music));
  mSearchView.setIconifiedByDefault(false);
  mSearchView.setIconified(false);
  MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.menu_search), new MenuItemCompat.OnActionExpandListener() {
    @Override
    public boolean onMenuItemActionExpand(MenuItem item) {
      return true;
    }
    @Override
    public boolean onMenuItemActionCollapse(MenuItem item) {
      finish();
      return false;
    }
  });
  menu.findItem(R.id.menu_search).expandActionView();
  return super.onCreateOptionsMenu(menu);
}

代码示例来源:origin: hidroh/materialistic

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  if (mIsMultiPane) {
    getMenuInflater().inflate(R.menu.menu_item_compact, menu);
  }
  if (isSearchable()) {
    getMenuInflater().inflate(R.menu.menu_search, menu);
    MenuItem menuSearch = menu.findItem(R.id.menu_search);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) mActionViewResolver.getActionView(menuSearch);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(
        new ComponentName(this, SearchActivity.class)));
    searchView.setIconified(true);
    searchView.setQuery("", false);
  }
  return super.onCreateOptionsMenu(menu);
}

代码示例来源:origin: hidroh/materialistic

private void createSearchView(MenuItem menuSearch) {
  final SearchView searchView = (SearchView) mActionViewResolver.getActionView(menuSearch);
  searchView.setQueryHint(getString(R.string.hint_search_saved_stories));
  searchView.setSearchableInfo(((SearchManager) getActivity()
      .getSystemService(Context.SEARCH_SERVICE))
      .getSearchableInfo(getActivity().getComponentName()));
  searchView.setIconified(!mSearchViewExpanded);
  searchView.setQuery(mFilter, false);
  searchView.setOnSearchClickListener(v -> {
    mSearchViewExpanded = true;
    v.requestFocus();
  });
  searchView.setOnCloseListener(() -> {
    // trigger a dummy empty search intent, as empty query does not get submitted
    searchView.setQuery(FavoriteActivity.EMPTY_QUERY, true);
    return false;
  });
}

代码示例来源:origin: aa112901/remusic

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
  getMenuInflater().inflate(R.menu.menu_search, menu);
  mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
  mSearchView.setOnQueryTextListener(this);
  mSearchView.setQueryHint(getResources().getString(R.string.search_local_music));
  mSearchView.setIconifiedByDefault(false);
  mSearchView.setIconified(false);
  MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.menu_search), new MenuItemCompat.OnActionExpandListener() {
    @Override
    public boolean onMenuItemActionExpand(MenuItem item) {
      return true;
    }
    @Override
    public boolean onMenuItemActionCollapse(MenuItem item) {
      finish();
      return false;
    }
  });
  menu.findItem(R.id.menu_search).expandActionView();
  return super.onCreateOptionsMenu(menu);
}

代码示例来源:origin: zulip/zulip-android

public void clearSearch() {
  //First time clears the searchEditText
  searchView.setIconified(true);
  //Second time closes the searchEditText
  searchView.setIconified(true);
  //Setting in search status to false
  inSearch = false;
}

代码示例来源:origin: naman14/Timber

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
  getMenuInflater().inflate(R.menu.menu_search, menu);
  mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.menu_search));
  mSearchView.setOnQueryTextListener(this);
  mSearchView.setQueryHint(getString(R.string.search_library));
  mSearchView.setIconifiedByDefault(false);
  mSearchView.setIconified(false);
  MenuItemCompat.setOnActionExpandListener(menu.findItem(R.id.menu_search), new MenuItemCompat.OnActionExpandListener() {
    @Override
    public boolean onMenuItemActionExpand(MenuItem item) {
      return true;
    }
    @Override
    public boolean onMenuItemActionCollapse(MenuItem item) {
      finish();
      return false;
    }
  });
  menu.findItem(R.id.menu_search).expandActionView();
  return super.onCreateOptionsMenu(menu);
}

代码示例来源:origin: AnyChart/AnyChart-Android

@Override
  public void onClick(View v) {
    searchView.setIconified(false);
  }
});

代码示例来源:origin: CityZenApp/Android-Development

@Override
  public void onClick(View view) {
    searchView.setIconified(false);//open searchView
  }
});

代码示例来源:origin: fennifith/Status

@Override
  public void onClick() {
    if (searchView != null) searchView.setIconified(false);
  }
}, false);

代码示例来源:origin: CityZenApp/Android-Development

@Override
  public void onClick(View view) {
    featuresSearchView.setIconified(false);//open searchView
  }
});

代码示例来源:origin: brkckr/TableView

@Override
public void onBackPressed()
{
  // close search view on back button pressed
  if (!searchView.isIconified())
  {
    searchView.setIconified(true);
    return;
  }
  super.onBackPressed();
}

代码示例来源:origin: HemendraGangwar/IntentSharingAnim

@Override
public boolean onQueryTextSubmit(String query) {
  Toast.makeText(HomeActivity.this, "item to search - " + query, Toast.LENGTH_SHORT).show();
  if (!searchView.isIconified()) {
    searchView.setIconified(true);
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    myActionMenuItem.collapseActionView();
  }
  return false;
}

代码示例来源:origin: Leaking/WeGit

@Override
public boolean onQueryTextSubmit(String query) {
  UIUtils.closeInputMethod(SearchActivity.this);
  searchView.setIconified(true);
  setItem.setVisible(true);
  Bundle bundle = new Bundle();
  bundle.putString("query", query);
  bundle.putSerializable("search_type", search_type);
  PreferenceUtils.appendStringToSet(SearchActivity.this, Constants.SEARCH_SUGGESTION, query);
  SearchResultActivity.launch(SearchActivity.this, bundle);
  return true;
}

代码示例来源:origin: CoderLengary/WanAndroid

@Override
public void initViews(View view) {
  layoutManager = new LinearLayoutManager(getContext());
  SearchActivity searchActivity = (SearchActivity) getActivity();
  toolbar = view.findViewById(R.id.toolBar);
  searchActivity.setSupportActionBar(toolbar);
  searchActivity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  searchView = view.findViewById(R.id.search_view);
  searchView.setIconified(false);
  recyclerView = view.findViewById(R.id.recycler_view);
  recyclerView.setLayoutManager(layoutManager);
  flowLayout = view.findViewById(R.id.flow_layout);
  emptyView = view.findViewById(R.id.empty_view);
}

代码示例来源:origin: adityak368/Android-FileBrowser-FilePicker

private void closeSearchView() {
    if (mSearchView.isShown()) {
      mSearchView.setQuery("", false);
      mSearchMenuItem.collapseActionView();
      mSearchView.setIconified(true);
    }
  }
}

代码示例来源:origin: adityak368/Android-FileBrowser-FilePicker

private void closeSearchView() {
    if (mSearchView.isShown()) {
      mSearchView.setQuery("", false);
      mSearchMenuItem.collapseActionView();
      mSearchView.setIconified(true);
    }
  }
}

代码示例来源:origin: adityak368/Android-FileBrowser-FilePicker

private void closeSearchView() {
    if (mSearchView.isShown()) {
      mSearchView.setQuery("", false);
      mSearchMenuItem.collapseActionView();
      mSearchView.setIconified(true);
    }
  }
}

代码示例来源:origin: AppLozic/Applozic-Android-SDK

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.menu_contact, menu);
  MenuItem searchItem = menu.findItem(R.id.menu_search);
  searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
  searchView.setQueryHint(getResources().getString(R.string.search_hint));
  if (Utils.hasICS()) {
    searchItem.collapseActionView();
  }
  searchView.setOnQueryTextListener(this);
  searchView.setSubmitButtonEnabled(true);
  searchView.setIconified(true);
  return super.onCreateOptionsMenu(menu);
}

代码示例来源:origin: avluis/Hentoid

/**
 * Clear search query and hide the search view if asked so
 * @param hideSearchView True if search view has to be hidden
 */
protected void clearQuery(boolean hideSearchView) {
  Timber.d("Clearing query with option: %s", hideSearchView);
  if (mainSearchView != null && hideSearchView) {
    mainSearchView.clearFocus();
    mainSearchView.setIconified(true);
  }
  setQuery(query = "");
  searchLibrary(true);
}

代码示例来源:origin: AppLozic/Applozic-Android-SDK

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.group_create_menu, menu);
  menu.removeItem(R.id.Next);
  if (disableCheckBox) {
    menu.removeItem(R.id.Done);
  }
  MenuItem searchItem = menu.findItem(R.id.menu_search);
  searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
  searchView.setQueryHint(getResources().getString(R.string.search_hint));
  if (Utils.hasICS()) {
    searchItem.collapseActionView();
  }
  searchView.setOnQueryTextListener(this);
  searchView.setIconified(true);
  return super.onCreateOptionsMenu(menu);
}

相关文章