使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Loader
加载在配置发生变化后继续存在的界面数据。
最近更新时间 |
稳定版 |
候选版 |
Beta 版 |
Alpha 版 |
2019 年 10 月 9 日 |
1.1.0 |
- |
- |
- |
声明依赖项
如需添加 Loader 的依赖项,您必须将 Google Maven 代码库添加到项目中。如需了解详情,请参阅 Google 的 Maven 代码库。
在应用或模块的 build.gradle
文件中添加所需工件的依赖项:
Groovy
dependencies {
implementation "androidx.loader:loader:1.1.0"
}
Kotlin
dependencies {
implementation("androidx.loader:loader:1.1.0")
}
如需详细了解依赖项,请参阅添加 build 依赖项。
反馈
您的反馈将帮助我们改进 Jetpack。如果您发现了新问题,或对此库有任何改进建议,请告诉我们。创建新问题前,请先查看此库中的现有问题。您可以点击星标按钮,为现有问题投票。
创建新问题
如需了解详情,请参阅问题跟踪器文档。
版本 1.1.0
版本 1.1.0
2019 年 10 月 9 日
发布了 androidx.loader:loader:1.1.0
。版本 1.1.0 中包含这些提交内容。
自 1.0.0 以来的重要变更
- 默认执行器更改:现在,
AsyncTaskLoader
(以及 CursorLoader
)的默认执行器是 AsyncTask.THREAD_POOL_EXECUTOR
,而不是自定义执行器。
- 设置自定义执行器:现在可以通过自定义实现
AsyncTaskLoader
或其子类来替换 getExecutor()
,从而设置自定义执行器。
版本 1.1.0-rc01
2019 年 6 月 5 日
发布了 androidx.loader:loader:1.1.0-rc01
,该版本与 1.1.0-beta01
相比没有变化。
版本 1.1.0-beta01
2019 年 3 月 13 日
发布了 androidx.loader:loader:1.1.0-beta01
。点击此处可查看此版本中包含的完整提交内容列表。
bug 修复
- 修复了从
onLoadFinished
重启加载器时会导致 StaleDataException
的问题 (b/123922776)
版本 1.1.0-alpha01
2018 年 12 月 3 日
新功能
- 将
getExecutor()
方法添加至 AsyncTaskLoader
,以便您可以设置自定义执行器 (aosp/810773)
行为变更
- 现在,
AsyncTaskLoader
的默认执行器是 AsyncTask.THREAD_POOL_EXECUTOR
,而不是自定义执行器。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-30。
[null,null,["最后更新时间 (UTC):2025-07-30。"],[],[],null,["# Loader\n======\n\n[User Guide](/guide/components/loaders) [Code Sample](https://github.com/android/architecture-components-samples/blob/master/PersistenceContentProviderSample/app/src/main/java/com/example/android/contentprovidersample/MainActivity.java) \nAPI Reference \n[androidx.loader.app](/reference/kotlin/androidx/loader/app/package-summary) \n[androidx.loader.content](/reference/kotlin/androidx/loader/content/package-summary) \nLoad data for your UI that survives configuration changes. \n\n| Latest Update | Stable Release | Release Candidate | Beta Release | Alpha Release |\n|-----------------|--------------------------------------------------|-------------------|--------------|---------------|\n| October 9, 2019 | [1.1.0](/jetpack/androidx/releases/loader#1.1.0) | - | - | - |\n\nDeclaring dependencies\n----------------------\n\nTo add a dependency on Loader, you must add the Google Maven repository to your\nproject. Read [Google's Maven repository](/studio/build/dependencies#google-maven)\nfor more information.\n\nAdd the dependencies for the artifacts you need in the `build.gradle` file for\nyour app or module: \n\n### Groovy\n\n```groovy\ndependencies {\n implementation \"androidx.loader:loader:1.1.0\"\n}\n```\n\n### Kotlin\n\n```kotlin\ndependencies {\n implementation(\"androidx.loader:loader:1.1.0\")\n}\n```\n\nFor more information about dependencies, see [Add build dependencies](/studio/build/dependencies).\n\nFeedback\n--------\n\nYour feedback helps make Jetpack better. Let us know if you discover new issues or have\nideas for improving this library. Please take a look at the\n[existing issues](https://issuetracker.google.com/issues?q=componentid:460551%20status:open)\nin this library before you create a new one. You can add your vote to an existing issue by\nclicking the star button.\n\n[Create a new issue](https://issuetracker.google.com/issues/new?component=460551&template=1182829)\n\nSee the [Issue Tracker documentation](https://developers.google.com/issue-tracker)\nfor more information.\n\nVersion 1.1.0\n-------------\n\n### Version 1.1.0\n\nOctober 9, 2019\n\n`androidx.loader:loader:1.1.0` is released. [Version 1.1.0 contains these commits](https://android.googlesource.com/platform/frameworks/support/+log/5201bd4b76d8abd612c147be0b4993f15ee133e3..5b6a7fdfd9ce612fa52f3fe95a9f9cb84fe9364c/loader).\n\n**Important changes since 1.0.0**\n\n- **Default Executor Change** : The default Executor for `AsyncTaskLoader` (and, by extension, `CursorLoader`) is now `AsyncTask.THREAD_POOL_EXECUTOR` rather than a custom Executor.\n- **Setting a custom Executor** : custom implementations of `AsyncTaskLoader` or its subclasses can now override `getExecutor()` to set a custom Executor.\n\n### Version 1.1.0-rc01\n\nJune 5, 2019\n\n`androidx.loader:loader:1.1.0-rc01` is released with no changes from `1.1.0-beta01`.\n\n### Version 1.1.0-beta01\n\nMarch 13, 2019\n\n`androidx.loader:loader:1.1.0-beta01` is released. The full list of commits included in this version can be found [here](https://android.googlesource.com/platform/frameworks/support/+log/b93a1415db20e4d3789c0f3a116f3d556ee6b603..79285e90f077844e4b3b1a72a4a051389e3c190a/loader).\n\n**Bug fixes**\n\n- Fixed an issue which would cause a `StaleDataException` when restarting loader from `onLoadFinished` ([b/123922776](https://issuetracker.google.com/issues/123922776))\n\n### Version 1.1.0-alpha01\n\nDecember 3, 2018\n\n**New features**\n\n- Added a `getExecutor()` method to `AsyncTaskLoader` to allow you to set a custom Executor ([aosp/810773](https://android-review.googlesource.com/c/platform/frameworks/support/+/810773))\n\n**Behavior changes**\n\n- The default Executor for `AsyncTaskLoader` is now `AsyncTask.THREAD_POOL_EXECUTOR` rather than a custom Executor."]]