Android应用旧API级别的LocalDate替代方法

huangapple go评论61阅读模式
英文:

android app LocalDate alternative for older API level

问题

我正在构建一个日历应用,在我的代码中主要使用LocalDate来设置我的RecyclerView和一些其他功能。我有一台平板电脑,其Android版本为7.1.1,因此无法运行与LocalDate相关的代码。

我想挑战自己,使我的应用程序能够在最低SDK版本16上运行。是否有任何替代LocalDate的选项适用于我的代码?我还在我的代码中使用Calendar,但是对于我的RecyclerView来说,需要几乎三倍的代码来执行相同的任务。任何其他建议将不胜感激。

英文:

I am building a calendar app and mostly in my code I use LocalDate to set my RecyclerView and some more functions.
I have a tablet that it's android version is 7.1.1, so it cant run anything in my code related to LocalDate.

I want to contest my self and make my app run to min SDK 16. Are there any alternatives for LocalDate for my code? I also use Calendar in my code but for my RecyclerView is almost the triple code to do same task. Any other suggestion would be apreciated.

答案1

得分: 2

如果您想在较低的Android版本中使用Java 8+功能,可以使用以下选项之一:

使用其中之一,您可以在Android API级别< 26中几乎使用java.time的所有类和函数,包括LocalDate

英文:

If you want to have Java 8+ features available in lower Android version, you can use one of the following options:

With (one of) these two, you can use nearly all of the classes and functions of java.time in Android API Levels < 26, including LocalDate.

huangapple
  • 本文由 发表于 2023年6月1日 20:54:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76382104.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定