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

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

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

SearchView.setMaxWidth介绍

暂无

代码示例

代码示例来源:origin: JZ-Darkal/AndroidHttpCapture

searchView.setFocusable(false);
searchView.setIconifiedByDefault(true);
searchView.setMaxWidth(Integer.MAX_VALUE);
searchView.setQueryHint("请输入URL关键字...");

代码示例来源:origin: eo/mdx

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  inflater.inflate(R.menu.fragment_icons, menu);
  MenuItem searchItem = menu.findItem(R.id.action_search);
  SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
  searchView.setQueryHint(getString(R.string.icon_search_hint));
  // reset max width to device width to make search view full width
  searchView.setMaxWidth(getResources().getDisplayMetrics().widthPixels);
  RxSearchView.queryTextChanges(searchView)
      .debounce(200, TimeUnit.MILLISECONDS)
      .skip(1)    // skip initial unnecessary change
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(new Action1<CharSequence>() {
        @Override
        public void call(CharSequence query) {
          mIconsPresenter.loadIcons(query);
        }
      });
}

代码示例来源:origin: yangchong211/YCAudioPlayer

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.menu_search_music, menu);
  SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
  searchView.setMaxWidth(Integer.MAX_VALUE);
  searchView.onActionViewExpanded();
  searchView.setQueryHint(getString(R.string.search_tips));
  searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
    @Override
    public boolean onQueryTextSubmit(String query) {
      searchMusic(query);
      return false;
    }
    @Override
    public boolean onQueryTextChange(String newText) {
      return false;
    }
  });
  searchView.setSubmitButtonEnabled(true);
  try {
    Field field = searchView.getClass().getDeclaredField("mGoButton");
    field.setAccessible(true);
    ImageView mGoButton = (ImageView) field.get(searchView);
    mGoButton.setImageResource(R.drawable.ic_menu_search);
  } catch (Exception e) {
    e.printStackTrace();
  }
  return super.onCreateOptionsMenu(menu);
}

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

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
  getMenuInflater().inflate(R.menu.menu_main, menu);
  // Associate searchable configuration with the SearchView
  SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
  searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
  searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
  searchView.setMaxWidth(Integer.MAX_VALUE);
  // listening to search query text change
  searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener()
  {
    @Override
    public boolean onQueryTextSubmit(String query)
    {
      // filter recycler view when query submitted
      clubAdapter.getFilter().filter(query);
      return false;
    }
    @Override
    public boolean onQueryTextChange(String query)
    {
      // filter recycler view when text is changed
      clubAdapter.getFilter().filter(query);
      return false;
    }
  });
  return true;
}

代码示例来源:origin: erikcaffrey/Android-Spotify-MVP

private void setupSearchView(Menu menu) {
 SearchManager searchManager =
   (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
 SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
 searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
 searchView.setQueryHint(getString(R.string.search_hint));
 searchView.setMaxWidth(toolbar.getWidth());
 searchView.setOnQueryTextListener(this);
}

代码示例来源:origin: andforce/iBeebo

searchView.setMaxWidth(Utility.dip2px(200));

相关文章