透過集合功能整理內容
你可以依據偏好儲存及分類內容。
載入器
載入在設定變更後仍然有效的 UI 資料。
最近更新時間 |
穩定版 |
候選版 |
Beta 版 |
Alpha 版 |
2019 年 10 月 9 日 |
1.1.0 |
- |
- |
- |
宣告依附元件
如要在載入器中新增依附元件,您必須將 Google Maven 存放區新增至專案。詳情請參閱 Google 的 Maven 存放區。
在應用程式或模組的 build.gradle
檔案中,新增所需構件的依附元件:
Groovy
dependencies {
implementation "androidx.loader:loader:1.1.0"
}
Kotlin
dependencies {
implementation("androidx.loader:loader:1.1.0")
}
如要進一步瞭解依附元件,請參閱「新增建構依附元件」一文。
意見回饋
您的意見可協助我們改善 Jetpack。如果您發現新問題,或是有改進這個程式庫的建議,請告訴我們。回報新問題前,請先查看這個程式庫的現有問題。只要按一下星號按鈕,即可投票給現有的問題。
建立新問題
詳情請參閱 Issue Tracker 說明文件。
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
。您可以前往這裡查看這個版本包含的修訂項目完整清單。
修正錯誤
- 修正從
onLoadFinished
重新啟動載入器時會發生 StaleDataException
的問題 (b/123922776)
1.1.0-alpha01 版本
2018 年 12 月 3 日
新功能
- 已將
getExecutor()
方法新增至 AsyncTaskLoader
,以便您設定自訂執行工具 (aosp/810773)
行為變更
AsyncTaskLoader
的預設執行者現在是 AsyncTask.THREAD_POOL_EXECUTOR
,而不是自訂執行者。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-30 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間: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."]]