在我的应用程序中,我正在使用自动完成搜索 View 的库 这是图书馆正在使用的东西
compile 'com.miguelcatalan:materialsearchview:1.4.0'
这是我的xml
<FrameLayout
android:id="@+id/toolbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/theme_primary" />
<com.miguelcatalan.materialsearchview.MaterialSearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
我想要的是我想以编程方式打开 searchView 以打开搜索栏,而无需按 actionbar
中的搜索图标。
我怎样才能做到这一点。任何帮助。
最佳答案
您可以使用该库必须扩展的 autocompletetextview 的内置功能
search_view.setFocusedByDefault(true);
关于java - Android - 强制搜索 View 以编程方式打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48905476/