我在 android 中使用 SearchView。当我第一次登陆该页面时,可见的只有搜索图标。然后,当我单击该图标时,会出现 EditText。如何让 EditText 从一开始就可见?这是我的 xml:
<SearchView
android:id="@+id/search"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:queryHint="@string/search_hint"
android:textSize="16sp" />
最佳答案
编辑---
对不起!我想你想做一个“空”查询。 我认为您可以使用以下方式以编程方式打开 SearchView:
searchView.setIconified(false);
旧答案--
在 Activity 中你可以尝试:
onSearchRequested();
在 Fragment 中你可以尝试:
getActivity().onSearchRequested();
祝你好运!
关于android - 默认显示 android SearchView EditText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20979238/