我正在使用搜索视图。它之前工作,它没有响应,我不能看到在搜索视图中输入的任何文本,也不会在文本发生更改时收回任何回调。Android搜索查看未显示任何文本
这里是XML布局文件,
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.SearchView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:iconifiedByDefault="false"
android:id="@+id/searchView"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/cardsRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"/>
</LinearLayout>
这里是我如何设置搜索查看回调,
EditText searchEditText = (EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
searchEditText.setTextColor(getResources().getColor(R.color.colorPrimary));
searchEditText.setHintTextColor(getResources().getColor(R.color.dark_grey));
searchView.setOnQueryTextListener(this);
我没有得到任何回调这些方法,当我在搜索查看类型。
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
filterCards(newText);
return false;
}
我在我的Fragment中实现了SearchView.OnQueryTextListener。
谢谢。
您是否试过我的解决方案? –
请显示'filterCards(newText);' –
@SohailZahid当我输入到SearchView时从未触发该方法 – Zach