此問題是後續到Show android SearchView EditText by default。我的SearchView用於正常工作,直到我將android:iconifiedByDefault="false"
添加到佈局。現在,當我點擊圖標或輸入搜索字段時,不會進行搜索。有誰知道如何解決這個問題?這是我的SearchView,因爲它現在存在。在Android SearchView原因視圖設置圖標化爲false無法搜索
<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" />
我已經試過如下:
mSearch.setOnSearchClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onSearchRequested();
//other stuff happen here
}
});