<SearchView
android:id="@+id/sv_city_world_clock"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:background="@drawable/shape_weather_search"
android:queryHint="@string/seatch_city"
android:searchIcon="@mipmap/icon_search"
android:iconifiedByDefault="false"
android:queryBackground="@null"
android:showDividers="none"
android:submitBackground="@null"
/>
sv_city_world_clock.onActionViewExpanded()
sv_city_world_clock.clearFocus()
sv_city_world_clock.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean {
Slog.d("提交")
return false
}
override fun onQueryTextChange(newText: String?): Boolean {
if (TextUtils.isEmpty(newText)) {
Slog.d("输入时激活 空")
} else {
Slog.d("输入时激活=2=$newText")
}
return true
}
})