当用户在填写SearchView
后按下默认软键按钮时,我需要触发搜索。
如何模拟用户按默认软键?
更新 根据需要,我的代码。
SearchText的xml定义:
<android.support.v7.widget.SearchView
android:id="@+id/search_box"
style="@style/AppTheme.SearchBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scrollbars="none"
android:soundEffectsEnabled="true" />
代码:
onView(withId(R.id.search_box))
.perform(typeSearchViewText("whatever query"),pressImeActionButton())
注意:typeSearchViewText
是我对typeText
SearchViews
的实施