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

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

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

SearchView.findViewById介绍

暂无

代码示例

代码示例来源:origin: tomahawk-player/tomahawk-android

@SuppressWarnings("unchecked")
public <T extends View> T getView(final int id) {
  if (id == 0) {
    return null;
  }
  View view = mSearchView.findViewById(id);
  return (T) view;
}

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

private void setSearchCursor() {
  final int textViewID = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
  final AutoCompleteTextView searchTextView = searchView.findViewById(textViewID);
  try {
    Field mCursorDrawableRes = TextView.class.getDeclaredField("mCursorDrawableRes");
    mCursorDrawableRes.setAccessible(true);
    mCursorDrawableRes.set(searchTextView, R.drawable.white_cursor);
  } catch (Exception ignored) {
  }
}

代码示例来源:origin: xbmc/Kore

@Override
  public void onClick(View v) {
    EditText editText = (EditText) searchView.findViewById(R.id.search_src_text);
    editText.setText("");
    searchView.setQuery("", false);
    searchFilter = savedSearchFilter = "";
    restartLoader();
  }
});

代码示例来源:origin: algolia/instantsearch-android

/**
 * Look for a child view with the given id.  If this view has the given
 * id, return this view.
 *
 * @param id The id to search for.
 * @return The view that has the given id in the hierarchy or null
 */
@Nullable public View findViewById(int id) {
  if (searchView != null) {
    return searchView.findViewById(id);
  } else if (supportView != null) {
    return supportView.findViewById(id);
  }
  throw new IllegalStateException(ERROR_NO_SEARCHVIEW);
}

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

EditText editTextSearch = ((EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text));
try {
  Field searchViewField = TextView.class.getDeclaredField("mCursorDrawableRes");

代码示例来源:origin: ABTSoftware/SciChart.Android.Examples

ImageView closeButton = (ImageView) searchView.findViewById(R.id.search_close_btn);
closeButton.setOnClickListener(new View.OnClickListener() {
  @Override

代码示例来源:origin: ymback/NGA-CLIENT-VER-OPEN-SOURCE

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.menu_search, menu);
  MenuItem item = menu.findItem(R.id.menu_search);
  item.expandActionView();
  item.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
    @Override
    public boolean onMenuItemActionExpand(MenuItem item) {
      return false;
    }
    @Override
    public boolean onMenuItemActionCollapse(MenuItem item) {
      SearchActivity.this.finish();
      return true;
    }
  });
  SearchView searchView = (SearchView) item.getActionView();
  mEditText = searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
  mEditText.setCursorVisible(true);
  mEditText.setOnEditorActionListener((v, actionId, event) -> {
    query(v.getText());
    return true;
  });
  updateTabChanged(SEARCH_MODE_TOPIC);
  return true;
}

代码示例来源:origin: chaychan/MaterialDesignExercise

mSearchAutoComplete = (SearchView.SearchAutoComplete) mSearchView.findViewById(R.id.search_src_text);

代码示例来源:origin: GitLqr/MaterialDesignDemo

mSearchAutoComplete = (SearchView.SearchAutoComplete) mSearchView.findViewById(R.id.search_src_text);
mSearchView.setQueryHint("搜索本地歌曲by code");
LinearLayout search_edit_frame = (LinearLayout) mSearchView.findViewById(R.id.search_edit_frame);
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) search_edit_frame.getLayoutParams();
params.leftMargin = 0;

代码示例来源:origin: xbmc/Kore

View view = searchView.findViewById(R.id.search_close_btn);
if (view != null) {
  view.setOnClickListener(new View.OnClickListener() {

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

@Override
public void removeChatBox(boolean animToRight) {
  if (!searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text).hasFocus()) {
    hideSoftKeyBoard();
  }
  AnimationHelper.hideViewX(chatBox, animToRight);
  //show fab button
  CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
  RemoveViewsOnScroll removeViewsOnScroll = (RemoveViewsOnScroll) layoutParams.getBehavior();
  removeViewsOnScroll.showView(fab);
}

代码示例来源:origin: byhieg/easyweather

AutoCompleteTextView textView = (AutoCompleteTextView)searchView.findViewById(R.id.search_src_text);
if (textView != null){
  textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);

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

searchView.setSearchableInfo(searchManager.getSearchableInfo(new ComponentName(getApplicationContext(), ZulipActivity.class)));
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
((EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text)).setHintTextColor(ContextCompat.getColor(this, R.color.colorTextPrimary));
searchView.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() {
  @Override

代码示例来源:origin: anitaa1990/TrailersApp

private void initialiseView() {
  binding = DataBindingUtil.setContentView(this, R.layout.activity_search);
  SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
  binding.search.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
  binding.search.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
  binding.search.setIconifiedByDefault(false);
  binding.search.setOnQueryTextListener(this);
  EditText searchEditText = binding.search.findViewById(android.support.v7.appcompat.R.id.search_src_text);
  searchEditText.setTextColor(getResources().getColor(android.R.color.white));
  searchEditText.setHintTextColor(getResources().getColor(android.R.color.white));
  Typeface myCustomFont = ResourcesCompat.getFont(getApplicationContext(), R.font.gt_medium);
  searchEditText.setTypeface(myCustomFont);
  searchListAdapter = new TvSearchListAdapter(this);
  binding.includedLayout.moviesList.setLayoutManager(new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL, false));
  binding.includedLayout.moviesList.setAdapter(searchListAdapter);
  SnapHelper startSnapHelper = new PagerSnapHelper(position -> {
    TvEntity trailer = searchListAdapter.getItem(position);
    updateBackground(trailer.getPosterPath());
  });
  startSnapHelper.attachToRecyclerView(binding.includedLayout.moviesList);
  binding.includedLayout.moviesList.addOnItemTouchListener(new RecyclerItemClickListener(getApplicationContext(), this));
}

代码示例来源:origin: anitaa1990/TrailersApp

private void initialiseView() {
  binding = DataBindingUtil.setContentView(this, R.layout.activity_search);
  SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
  binding.search.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
  binding.search.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
  binding.search.setIconifiedByDefault(false);
  binding.search.setOnQueryTextListener(this);
  EditText searchEditText = binding.search.findViewById(android.support.v7.appcompat.R.id.search_src_text);
  searchEditText.setTextColor(getResources().getColor(android.R.color.white));
  searchEditText.setHintTextColor(getResources().getColor(android.R.color.white));
  Typeface myCustomFont = ResourcesCompat.getFont(getApplicationContext(), R.font.gt_medium);
  searchEditText.setTypeface(myCustomFont);
  searchListAdapter = new MovieSearchListAdapter(this);
  binding.includedLayout.moviesList.setLayoutManager(new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL, false));
  binding.includedLayout.moviesList.setAdapter(searchListAdapter);
  SnapHelper startSnapHelper = new PagerSnapHelper(position -> {
    MovieEntity trailer = searchListAdapter.getItem(position);
    updateBackground(trailer.getPosterPath());
  });
  startSnapHelper.attachToRecyclerView(binding.includedLayout.moviesList);
  binding.includedLayout.moviesList.addOnItemTouchListener(new RecyclerItemClickListener(getApplicationContext(), this));
}

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

相关文章