android - Android 搜索视图删除十字图标
问题描述
我根据我的设计使用自定义工具栏中的搜索视图,我有另一个十字图标,所以我想删除十字图标以在默认情况下由 android 提供的搜索视图。
<SearchView
android:id="@+id/search_learning_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:queryHint="@string/toolBar_hint"
android:clickable="true"
android:searchIcon="@null"
android:paddingTop="@dimen/element_padding_small"
android:focusable="false"
android:paddingBottom="@dimen/element_padding_small"
android:background="@color/White"
android:queryBackground="@color/White"
android:iconifiedByDefault="false"
android:layout_alignParentTop="true">
</SearchView>
ImageView searchViewIcon = (ImageView)searchView.findViewById(R.id.search_close_btn);
searchViewIcon.setVisibility(View.GONE);
Toast.makeText(CustomSearchActivity.this, ""+searchViewIcon, Toast.LENGTH_SHORT).show();
解决方案
使用它来做到这一点-
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextChange(String query) {
ImageView searchViewIcon = (ImageView)searchView.findViewById(android.support.v7.appcompat.R.id.search_close_btn);
searchViewIcon.setVisibility(View.GONE);
return true;
}
});
推荐阅读
- coq - Coq 不会减少涉及决策过程的表达式
- typescript - 在打字稿中定义模型
- java - 希望打印所有可能的解决方案
- excel - 通过 Function / Name 设置非连续 PrintArea
- html - 编辑引导类
- python-3.x - 动画情节在几秒钟后变慢了,我怎样才能让它保持快速运行?
- java - 如何检查列表是否
包含一个类,同时避免声纳规则 squid:S2175 - kotlin - livedata postvalue是否需要observeOn?
- php - 无法打开共享对象文件:amazon-elasticache-cluster-client.so 没有这样的文件或目录
- python - 如何在 Python 中使用 zeep 设置默认 xmlns?