哪个SearchView适用于更高的API?

问题描述 投票:1回答:1

我正在使用RecyclerView和SearchView。

但我不知道该用什么。

在Android Developer中,android.support.v7.widget.SearchView

https://developer.android.com/reference/android/support/v7/widget/SearchView

Note: This class is included in the support library for compatibility with API level 7 and higher. If you're developing your app for API level 11 and higher only, you should instead use the framework SearchView class.

所以我想我必须使用另一个SearchView。 android.widget.SearchView

https://developer.android.com/reference/android/widget/SearchView.html

但是,在版本25.1.0中添加了android.support.v7.widget.SearchView,在API级别11中添加了android.widget.SearchView。

哪个SearchView适合最近的API?我正在使用API​​ 26模拟器。 (我将在以后更新我的app以获得更高的API ex.API27,API28 ......)谢谢:)

android searchview
1个回答
-2
投票

使用android.widget.SearchView,它比支持版本更灵活。

升级延迟与常规新版本相结合,使兼容性成为Android编程中的一个重要问题。

将新功能添加到API时,支持库会快速更新,但仍缺少许多不向后兼容的功能。

如果谷歌明确表示要使用android.widget.SearchView,那么你应该使用它。

而像RecyclerView这样的一些API仍然使用v7支持版本,因为Google选择在支持版本中提供新的和向后兼容的功能。

因此,您应检查lint警告并考虑官方开发人员指南,以防任何API被折旧。

© www.soinside.com 2019 - 2024. All rights reserved.