设置图标化在Android上搜索查看原因视图假以不可搜索 [英] Setting iconified to false on android SearchView cause view to not be searchable
本文介绍了设置图标化在Android上搜索查看原因视图假以不可搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这问题是一个跟进默认显示Android的搜索查看的EditText 。我用搜索查看做工精细,直到我加入的android:iconifiedByDefault =FALSE
的布局。现在,当我点击图标或键入搜索领域,没有搜索发生。有谁知道如何解决这个问题?这里是我的搜索查看,因为它现在已经存在。
<搜索查看
机器人:ID =@ + ID /搜索
机器人:layout_width =0dp
机器人:layout_height =match_parent
机器人:layout_weight =1
机器人:queryHint =@字符串/ search_hint
机器人:iconifiedByDefault =假
机器人:TEXTSIZE =16SP/>
我已经尝试了以下内容:
mSearch.setOnSearchClickListener(新OnClickListener(){ @覆盖
公共无效的onClick(视图v){
getActivity()onSearchRequested()。
//其他的东西发生在这里
}
});
解决方案
我解决了。
问题 公共无效onFocusChange(视图V,布尔hasFocus){
如果(hasFocus){...}
}
This question is a follow up to Show android SearchView EditText by default. My SearchView used to work fine until I added android:iconifiedByDefault="false"
to the layout. Now, when I click on the icon or type in the search field, no search takes place. Does anyone know how to fix this problem? here is my SearchView as it exists now.
<SearchView
android:id="@+id/search"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:queryHint="@string/search_hint"
android:iconifiedByDefault="false"
android:textSize="16sp" />
I already tried the following:
mSearch.setOnSearchClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onSearchRequested();
//other stuff happen here
}
});
解决方案
I solved the problem with
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) { ...}
}
这篇关于设置图标化在Android上搜索查看原因视图假以不可搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文