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

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

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

SearchView.setSubmitButtonEnabled介绍

暂无

代码示例

代码示例来源: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: 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: Swati4star/Images-to-PDF

mSearchView = (SearchView) item.getActionView();
mSearchView.setQueryHint(getString(R.string.search_hint));
mSearchView.setSubmitButtonEnabled(true);
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
  @Override

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

@SuppressLint("NewApi")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  showActionBar();
  //return false;
  getMenuInflater().inflate(R.menu.mobicom_basic_menu_for_normal_message, 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.setIconifiedByDefault(true);
  if (quickConversationFragment != null && !TextUtils.isEmpty(quickConversationFragment.getSearchString())) {
    searchView.setIconified(false);
    searchView.setQuery(quickConversationFragment.getSearchString(), false);
  }
  return super.onCreateOptionsMenu(menu);
}

代码示例来源:origin: 0xZhangKe/ShiZhong

private void setupSearchView(final SearchView searchView) {
  searchView.setIconified(true);
  searchView.setIconifiedByDefault(false);
  searchView.setSubmitButtonEnabled(true);
  searchView.setFocusable(true);
  searchView.requestFocusFromTouch();
  searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
    @Override
    public boolean onQueryTextSubmit(String query) {
      return false;
    }
    @Override
    public boolean onQueryTextChange(String newText) {
      curQueryText = newText;
      search();
      return true;
    }
  });
}

代码示例来源:origin: amahi/android

private void setUpSearchView() {
  SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
  searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
  searchView.setSubmitButtonEnabled(false);
  searchView.setOnQueryTextListener(this);
}

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

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

代码示例来源:origin: CooLoongWu/CoolChat

private void initViews() {
  layout_points = (LinearLayout) findViewById(R.id.layout_points);
  SearchView searchView = (SearchView) findViewById(R.id.search_view);
  //设置显示提交按钮
  searchView.setSubmitButtonEnabled(true);
  //一开始就处于显示SearchView的状态
  searchView.setIconifiedByDefault(false);
  //设置一开始就显示输入框
  searchView.setIconified(true);
  searchView.clearFocus();
  SearchView.SearchAutoComplete editText = (SearchView.SearchAutoComplete) searchView.findViewById(R.id.search_src_text);
  editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
  searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
    @Override
    public boolean onQueryTextSubmit(String query) {
      searchFriend(query.trim());
      return false;
    }
    @Override
    public boolean onQueryTextChange(String newText) {
      if (!newText.isEmpty()) {
        searchFriend(newText);
      }
      return false;
    }
  });
}

代码示例来源:origin: szpnygo/NoWordsChat

@Override
protected void onCreateDataBinding() {
  super.onCreateDataBinding();
  binding = createContentView(R.layout.activity_add_friend);
  binding.toolbar.setTitle("添加好友");
  setSupportActionBar(binding.toolbar);
  setToolbarFinish(binding.toolbar);
  binding.setUserBean(UserInfoAction.getUserInfo());
  binding.searchView.requestFocus();
  binding.searchView.requestFocusFromTouch();
  binding.searchView.onActionViewExpanded();
  binding.searchView.setSubmitButtonEnabled(true);
  binding.searchView.setIconifiedByDefault(false);
  binding.searchView.setIconified(false);
  binding.searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
    @Override
    public boolean onQueryTextSubmit(String query) {
      if (StringUtil.isEmpty(query)) {
        showSnackbarMessage("请输入要查询的无语号");
      } else {
        search(query);
      }
      return false;
    }
    @Override
    public boolean onQueryTextChange(String newText) {
      return false;
    }
  });
}

相关文章