自 1.2 版起,大多數的資訊方塊版面配置 API 都位於 androidx.wear.protolayout
命名空間中。如要使用最新的 API,請完成下列程式碼遷移步驟。
更新依附元件
在應用程式模組的建構檔案中進行下列變更:
// Remove
implementation 'androidx.wear.tiles:tiles-material:version '
// Include additional dependencies
implementation "androidx.wear.protolayout:protolayout:1.3.0-alpha03"
implementation "androidx.wear.protolayout:protolayout-material:1.3.0-alpha03"
implementation "androidx.wear.protolayout:protolayout-expression:1.3.0-alpha03"
// Update
implementation "androidx.wear.tiles:tiles:1.5.0-alpha03"
// Remove
implementation("androidx.wear.tiles:tiles-material:version ")
// Include additional dependencies
implementation("androidx.wear.protolayout:protolayout:1.3.0-alpha03")
implementation("androidx.wear.protolayout:protolayout-material:1.3.0-alpha03")
implementation("androidx.wear.protolayout:protolayout-expression:1.3.0-alpha03")
// Update
implementation("androidx.wear.tiles:tiles:1.5.0-alpha03")
更新命名空間
在應用程式的 Kotlin 和 Java 程式碼檔案中進行下列更新。或者,您也可以執行這段命名空間重新命名指令碼。
- 將所有的
androidx.wear.tiles.material.*
匯入項目替換為androidx.wear.protolayout.material.*
。請同時為androidx.wear.tiles.material.layouts
程式庫完成這個步驟。 將大多數其他
androidx.wear.tiles.*
匯入項目替換為androidx.wear.protolayout.*
。androidx.wear.tiles.EventBuilders
、androidx.wear.tiles.RequestBuilders
、androidx.wear.tiles.TileBuilders
和androidx.wear.tiles.TileService
的匯入項目應維持不變。重新命名 TileService 和 TileBuilder 類別的幾個已淘汰的方法:
TileBuilders
:將getTimeline()
重新命名為getTileTimeline()
、setTimeline()
重新命名為setTileTimeline()
TileService
:將onResourcesRequest()
重新命名為onTileResourcesRequest()
RequestBuilders.TileRequest
:將getDeviceParameters()
重新命名為getDeviceConfiguration()
、setDeviceParameters()
重新命名為setDeviceConfiguration()
、getState()
重新命名為getCurrentState()
,以及setState()
重新命名為setCurrentState()
目前沒有任何建議。
建議登入 Google 帳戶。