建立與先前版本相容的 UI
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
這個類別示範如何以回溯相容的方式使用新版 Android 中可用的 UI 元件和 API,確保您的應用程式仍可在先前的平台版本上執行。
在本課程中,Android 3.0 (API 級別 11) 中導入的「動作列分頁」功能可做為指導範例,但您可以將這些技巧套用至其他 UI 元件和 API 功能。
課程
- 抽像新 API
- 決定應用程式需要的功能和 API。瞭解如何定義應用程式專屬的中介 Java 介面,將 UI 元件導入應用程式。
- Proxy 遷移至新 API
- 瞭解如何使用新版 API 建立介面實作。
- 使用較舊的 API 建立實作
- 瞭解如何使用舊版 API 建立自訂介面實作。
- 使用可因應不同版本的元件
- 瞭解如何選擇在執行階段中使用的實作方式,並在應用程式中開始使用介面。
另請參閱
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2024-02-22 (世界標準時間)。
[[["容易理解","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"]],["上次更新時間:2024-02-22 (世界標準時間)。"],[],[],null,["# Create backward-compatible UIs\n\nThis class demonstrates how to use UI components and APIs available in newer versions of Android in a backward-compatible way, ensuring that your application still runs on previous versions of the platform.\n\nThroughout this class, the new [Action Bar Tabs](/guide/topics/ui/actionbar#Tabs) feature introduced in Android 3.0 (API level 11) serves as the guiding example, but you can apply these techniques to other UI components and API features.\n\nLessons\n-------\n\n**[Abstract the new APIs](/training/backward-compatible-ui/abstracting)**\n: Determine which features and APIs your application needs. Learn how to define application-specific, intermediary Java interfaces that abstract the implementation of the UI component to your application.\n\n**[Proxy to the new APIs](/training/backward-compatible-ui/new-implementation)**\n: Learn how to create an implementation of your interface that uses newer APIs.\n\n**[Create an implementation with older APIs](/training/backward-compatible-ui/older-implementation)**\n: Learn how to create a custom implementation of your interface that uses older APIs.\n\n**[Use the version-aware component](/training/backward-compatible-ui/using-component)**\n: Learn how to choose an implementation to use at runtime, and begin using the interface in your application.\n\n### You should also read\n\n- [How to have your (Cup)cake and eat it too](http://android-developers.blogspot.com/2010/07/how-to-have-your-cupcake-and-eat-it-too.html)"]]