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

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

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

SearchView.setQueryHint介绍

暂无

代码示例

代码示例来源: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: 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: 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: JZ-Darkal/AndroidHttpCapture

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

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

@Override
  public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
    if(which == 0){
      searchView.setQueryHint(getResources().getString(R.string.search_user));
      search_type = SEARCH_TYPE.SEARCH_USER;
    }else if(which == 1){
      searchView.setQueryHint(getResources().getString(R.string.search_repository));
      search_type = SEARCH_TYPE.SEARCH_REPO;
    }
    return true;
  }
})

代码示例来源:origin: garretyoder/app-theme-engine

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

    final MenuItem searchItem = menu.findItem(R.id.search);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setQueryHint(getString(R.string.search_view_example));
//        searchView.setIconifiedByDefault(false);
//        searchItem.expandActionView();

    return super.onCreateOptionsMenu(menu);
  }

代码示例来源:origin: nglauber/dominando_android2

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.menu_hotel, menu);
  MenuItem searchItem = menu.findItem(R.id.action_search);
  SearchView searchView = (SearchView)
      MenuItemCompat.getActionView(searchItem);
  searchView.setOnQueryTextListener(this);
  searchView.setQueryHint(getString(R.string.hint_busca));
  MenuItemCompat.setOnActionExpandListener(searchItem, this);
  return true;
}

代码示例来源:origin: nglauber/dominando_android2

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.menu_hotel, menu);
  MenuItem searchItem = menu.findItem(R.id.action_search);
  SearchView searchView = (SearchView)
      MenuItemCompat.getActionView(searchItem);
  searchView.setOnQueryTextListener(this);
  searchView.setQueryHint(getString(R.string.hint_busca));
  MenuItemCompat.setOnActionExpandListener(searchItem, this);
  return true;
}

代码示例来源:origin: nglauber/dominando_android2

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.menu_hotel, menu);
  MenuItem searchItem = menu.findItem(R.id.action_search);
  SearchView searchView = (SearchView)
      MenuItemCompat.getActionView(searchItem);
  searchView.setOnQueryTextListener(this);
  searchView.setQueryHint(getString(R.string.hint_busca));
  MenuItemCompat.setOnActionExpandListener(searchItem, this);
  return true;
}

代码示例来源:origin: nglauber/dominando_android2

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.menu_hotel, menu);
  MenuItem searchItem = menu.findItem(R.id.action_search);
  SearchView searchView = (SearchView)
      MenuItemCompat.getActionView(searchItem);
  searchView.setOnQueryTextListener(this);
  searchView.setQueryHint(getString(R.string.hint_busca));
  MenuItemCompat.setOnActionExpandListener(searchItem, this);
  return true;
}

代码示例来源:origin: nglauber/dominando_android2

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.menu_hotel, menu);
  MenuItem searchItem = menu.findItem(R.id.action_search);
  SearchView searchView = (SearchView)
      MenuItemCompat.getActionView(searchItem);
  searchView.setOnQueryTextListener(this);
  searchView.setQueryHint(getString(R.string.hint_busca));
  MenuItemCompat.setOnActionExpandListener(searchItem, this);
  return true;
}

代码示例来源:origin: nglauber/dominando_android2

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.menu_hotel, menu);
  MenuItem searchItem = menu.findItem(R.id.action_search);
  SearchView searchView = (SearchView)
      MenuItemCompat.getActionView(searchItem);
  searchView.setOnQueryTextListener(this);
  searchView.setQueryHint(getString(R.string.hint_busca));
  MenuItemCompat.setOnActionExpandListener(searchItem, this);
  return true;
}

代码示例来源:origin: aint/laverna-android

@Override
  public void switchToSearchMode() {
//        menuSync.setVisible(false);
//        menuAbout.setVisible(false);
//        menuSortBy.setVisible(false);
//        menuSettings.setVisible(false);
    mSearchView.setQueryHint(getString(R.string.fragment_all_notes_menu_search_query_hint));
    mSearchView.requestFocus();
    Drawable bottomUnderline = null;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
      bottomUnderline = getResources().getDrawable(R.drawable.search_view_bottom_underline, null);
    }
    mSearchView.setBackground(bottomUnderline);
  }

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

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  if (!isAdded()) {
    // HACK: Fix crash reported on Play Store. Why does this is necessary is beyond me
    super.onCreateOptionsMenu(menu, inflater);
    return;
  }
  inflater.inflate(R.menu.media_search, menu);
  MenuItem searchItem = menu.findItem(R.id.action_search);
  SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
  searchView.setOnQueryTextListener(this);
  searchView.setQueryHint(getString(R.string.action_search_albums));
  super.onCreateOptionsMenu(menu, inflater);
}

代码示例来源:origin: materialos/android-icon-pack

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  inflater.inflate(R.menu.icons, menu);
  super.onCreateOptionsMenu(menu, inflater);
  MenuItem mSearchItem = menu.findItem(R.id.search);
  SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem);
  mSearchView.setQueryHint(getString(R.string.search_icons));
  mSearchView.setOnQueryTextListener(this);
  mSearchView.setOnCloseListener(this);
  mSearchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
  if (getActivity() != null) {
    final BaseThemedActivity act = (BaseThemedActivity) getActivity();
    TintUtils.themeSearchView(act.getToolbar(), mSearchView, DialogUtils.resolveColor(act, R.attr.tab_icon_color));
  }
}

代码示例来源:origin: materialos/android-icon-pack

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  inflater.inflate(R.menu.wallpapers, menu);
  super.onCreateOptionsMenu(menu, inflater);
  MenuItem mSearchItem = menu.findItem(R.id.search);
  SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem);
  mSearchView.setQueryHint(getString(R.string.search_wallpapers));
  mSearchView.setOnQueryTextListener(this);
  mSearchView.setOnCloseListener(this);
  mSearchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
  if (getActivity() != null) {
    final MainActivity act = (MainActivity) getActivity();
    TintUtils.themeSearchView(act.getToolbar(), mSearchView, DialogUtils.resolveColor(act, R.attr.tab_icon_color));
  }
}

代码示例来源:origin: materialos/android-icon-pack

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  inflater.inflate(R.menu.kustom, menu);
  super.onCreateOptionsMenu(menu, inflater);
  MenuItem mSearchItem = menu.findItem(R.id.search);
  SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchItem);
  mSearchView.setQueryHint(getString(getSearchHintRes()));
  mSearchView.setOnQueryTextListener(this);
  mSearchView.setOnCloseListener(this);
  mSearchView.setImeOptions(EditorInfo.IME_ACTION_DONE);
  if (getActivity() != null) {
    final MainActivity act = (MainActivity) getActivity();
    TintUtils.themeSearchView(act.getToolbar(), mSearchView, DialogUtils.resolveColor(act, R.attr.tab_icon_color));
  }
}

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

相关文章