Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Loader
Tải dữ liệu cho giao diện người dùng vẫn tồn tại sau khi thay đổi cấu hình.
Bản cập nhật mới nhất |
Bản phát hành ổn định |
Bản phát hành dùng thử |
Bản phát hành beta |
Bản phát hành alpha |
Ngày 9 tháng 10 năm 2019 |
1.1.0 |
- |
- |
- |
Khai báo phần phụ thuộc
Để thêm một phần phụ thuộc trên Loader, bạn phải thêm kho lưu trữ Google Maven vào dự án. Đọc nội dung Kho lưu trữ Maven của Google để biết thêm thông tin.
Thêm các phần phụ thuộc cho cấu phần phần mềm bạn cần trong tệp build.gradle
cho ứng dụng hoặc mô-đun:
Groovy
dependencies {
implementation "androidx.loader:loader:1.1.0"
}
Kotlin
dependencies {
implementation("androidx.loader:loader:1.1.0")
}
Để biết thêm thông tin về các phần phụ thuộc, hãy xem bài viết Thêm phần phụ thuộc vào bản dựng.
Ý kiến phản hồi
Ý kiến phản hồi của bạn có thể giúp chúng tôi cải thiện Jetpack. Hãy cho chúng tôi biết nếu bạn phát hiện lỗi mới hoặc có ý tưởng cải thiện thư viện này. Vui lòng xem các lỗi hiện có trong thư viện này trước khi báo một lỗi mới. Bạn có thể thêm lượt bình chọn cho lỗi hiện có bằng cách nhấp vào nút dấu sao.
Báo lỗi mới
Xem tài liệu về Công cụ theo dõi lỗi để biết thêm thông tin.
Phiên bản 1.1.0
Phiên bản 1.1.0
Ngày 9 tháng 10 năm 2019
Phát hành androidx.loader:loader:1.1.0
. Phiên bản 1.1.0 bao gồm các thay đổi sau.
Thay đổi quan trọng kể từ phiên bản 1.0.0
- Thay đổi Trình thực thi mặc định: Trình thực thi (Executor) mặc định cho
AsyncTaskLoader
(và theo tiện ích, CursorLoader
) hiện là AsyncTask.THREAD_POOL_EXECUTOR
thay vì Trình thực thi tuỳ chỉnh.
- Đặt Trình thực thi tuỳ chỉnh: các quy trình triển khai tuỳ chỉnh của
AsyncTaskLoader
hoặc lớp con của lớp này hiện có thể ghi đè getExecutor()
để đặt Trình thực thi tuỳ chỉnh.
Phiên bản 1.1.0-rc01
Ngày 5 tháng 6 năm 2019
androidx.loader:loader:1.1.0-rc01
được phát hành mà không có thay đổi nào từ 1.1.0-beta01
.
Phiên bản 1.1.0-beta01
Ngày 13 tháng 3 năm 2019
Phát hành androidx.loader:loader:1.1.0-beta01
. Bạn có thể xem danh sách đầy đủ các thay đổi trong phiên bản này tại đây.
Sửa lỗi
- Khắc phục sự cố gây ra
StaleDataException
khi khởi động lại trình tải từ onLoadFinished
(b/123922776)
Phiên bản 1.1.0-alpha01
Ngày 3 tháng 12 năm 2018
Tính năng mới
- Thêm phương thức
getExecutor()
vào AsyncTaskLoader
để cho phép bạn đặt Trình thực thi tuỳ chỉnh (aosp/810773)
Thay đổi về hành vi
- Trình thực thi mặc định cho
AsyncTaskLoader
hiện là
AsyncTask.THREAD_POOL_EXECUTOR
thay vì Trình thực thi tuỳ chỉnh.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-30 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-30 UTC."],[],[],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."]]