新聞中心
ResourceManager

創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比興隆臺網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式興隆臺網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋興隆臺地區(qū)。費用合理售后完善,10余年實體公司更值得信賴。
java.lang.Object
|---ohos.global.resource.ResourceManager
public abstract class ResourceManager
extends Object管理應(yīng)用程序包資源目錄下的所有資源。
ResourceManager 實例僅從上下文中獲取。
Since:
1
構(gòu)造函數(shù)摘要
| 構(gòu)造函數(shù) | 描述 |
|---|---|
| ResourceManager() |
方法總結(jié)
| 修飾符和類型 | 方法 | 描述 |
|---|---|---|
| abstract Pattern | createPattern(ListTypedAttribute.AttrData data) | 基于包含 TypedAttribute.AttrData 的數(shù)組創(chuàng)建 Pattern 實例。 |
| abstract Theme | createTheme(ListTypedAttribute.AttrData data) | 基于包含 TypedAttribute.AttrData 的數(shù)組創(chuàng)建一個 Theme 實例。 |
| abstract ConfigManager | getConfigManager() | 獲取 ConfigManager 以獲取全局配置。 |
| abstract Configuration | getConfiguration() | 獲取當(dāng)前配置。 |
| abstract DeviceCapability | getDeviceCapability() | 獲取設(shè)備能力。 |
| abstract Element | getElement(int resId) | 根據(jù)資源 ID 獲取 Element 對象。 |
| abstract String | getIdentifier(int resId) | 根據(jù)資源ID獲取資源名稱。 |
| abstract String | getMediaPath(int resId) | 根據(jù)資源ID獲取媒體文件路徑。 |
| abstract RawFileEntry | getRawFileEntry(String path) | 根據(jù)原始文件路徑獲取 RawFileEntry 對象以打開原始文件。 |
| abstract Resource | getResource(int resId) | 根據(jù)資源ID獲取資源。 |
| abstract SolidXml | getSolidXml(int resId) | 根據(jù)資源 ID 獲取一個可靠的 XML 文檔。 |
| abstract Theme | getTheme(int resId) | 已棄用。 此更改從 API 版本 4 開始生效。由 Element#getTheme() 替換 |
| abstract void | updateConfiguration(Configuration config, DeviceCapability capability) | 通過修改配置和設(shè)備能力來更新配置。 |
| 從類 java.lang.Object 繼承的方法 |
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
構(gòu)造函數(shù)詳細(xì)信息
ResourceManager
public ResourceManager()
方法詳情
getResource
public abstract Resource getResource(int resId) throws IOException, NotExistException
根據(jù)資源ID獲取資源。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| resId | 表示資源ID。 |
返回:
返回資源對象; 如果資源 ID 不匹配任何資源,則返回 null。
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| NotExistException | 如果資源 ID 與任何資源都不匹配,則引發(fā)此異常。 資源ID必須由IDE或資源工具自動生成,或者由系統(tǒng)提供。 |
| IOException | 如果在資源讀取期間發(fā)生 I/O 錯誤,則引發(fā)此異常。 |
getIdentifier
public abstract String getIdentifier(int resId) throws IOException, NotExistException
根據(jù)資源ID獲取資源名稱。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| resId | 表示資源ID。 |
返回:
返回類型為 type_name 的資源名稱; 如果資源 ID 不匹配任何資源,則返回 null。
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| NotExistException | 如果資源 ID 與任何資源都不匹配,則引發(fā)此異常。 資源ID必須由IDE或資源工具自動生成,或者由系統(tǒng)提供。 |
| IOException | 如果在資源讀取期間發(fā)生 I/O 錯誤,則引發(fā)此異常。 |
getElement
public abstract Element getElement(int resId) throws IOException, NotExistException, WrongTypeException
根據(jù)資源 ID 獲取 Element 對象。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| resId | 表示資源ID。 |
返回:
返回與資源 ID 關(guān)聯(lián)的 Element 對象。
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| NotExistException | 如果資源 ID 與任何資源都不匹配,則引發(fā)此異常。 資源ID必須由IDE或資源工具自動生成,或者由系統(tǒng)提供。 |
| IOException | 如果在資源讀取期間發(fā)生 I/O 錯誤,則引發(fā)此異常。 |
| WrongTypeException | 如果資源不是 Element 類型,則引發(fā)此異常。 |
Since:
3
getTheme
@Deprecated public abstract Theme getTheme(int resId) throws IOException, NotExistException, WrongTypeException
已棄用。 此更改從 API 版本 4 開始生效。由 Element#getTheme() 替換
根據(jù)資源 ID 獲取 Theme 實例。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| resId | 表示資源ID。 |
返回:
返回一個主題實例。
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| NotExistException | 如果資源 ID 與任何資源都不匹配,則引發(fā)此異常。 資源ID必須由IDE或資源工具自動生成,或者由系統(tǒng)提供。 |
| IOException | 如果在資源讀取期間發(fā)生 I/O 錯誤,則引發(fā)此異常。 |
| WrongTypeException | 如果資源不是主題類型,則引發(fā)此異常。 |
Since:
3
getSolidXml
public abstract SolidXml getSolidXml(int resId) throws IOException, NotExistException, WrongTypeException
根據(jù)資源 ID 獲取一個可靠的 XML 文檔。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| resId | 表示資源ID。 |
返回:
返回資源的實體 XML 文檔; 如果在轉(zhuǎn)換為實體 XML 文檔期間發(fā)生錯誤,則返回 null。
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| NotExistException | 如果資源 ID 與任何資源都不匹配,則引發(fā)此異常。 資源ID必須由IDE或資源工具自動生成,或者由系統(tǒng)提供。 |
| IOException | 如果在資源讀取期間發(fā)生 I/O 錯誤,則引發(fā)此異常。 |
| WrongTypeException | 如果資源不是 Solid XML 類型,則引發(fā)此異常。 |
getRawFileEntry
public abstract RawFileEntry getRawFileEntry(String path)
根據(jù)原始文件路徑獲取 RawFileEntry 對象以打開原始文件。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| path | 指示原始文件路徑。 |
返回:
返回 RawFileEntry 對象。
Since:
3
getConfigManager
public abstract ConfigManager getConfigManager()
獲取 ConfigManager 以獲取全局配置。
返回:
返回 ConfigManager 對象; 如果發(fā)生錯誤,則返回 null。
getMediaPath
public abstract String getMediaPath(int resId) throws IOException, NotExistException, WrongTypeException
根據(jù)資源ID獲取媒體文件路徑。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| resId | 表示資源ID。 |
返回:
返回媒體文件路徑。
Throws:
| Throw名稱 | Throw描述 |
|---|---|
| NotExistException | 如果資源 ID 與任何資源都不匹配,則引發(fā)此異常。 資源ID必須由IDE或資源工具自動生成,或者由系統(tǒng)提供。 |
| IOException | 如果在資源讀取期間發(fā)生 I/O 錯誤,則引發(fā)此異常。 |
| WrongTypeException | 如果資源不是字符串類型,則引發(fā)此異常。 |
getConfiguration
public abstract Configuration getConfiguration()
獲取當(dāng)前配置。
返回:
返回當(dāng)前配置。
getDeviceCapability
public abstract DeviceCapability getDeviceCapability()
獲取設(shè)備能力。
返回:
返回設(shè)備能力。
Since:
3
updateConfiguration
public abstract void updateConfiguration(Configuration config, DeviceCapability capability)
通過修改配置和設(shè)備能力來更新配置。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| config | 表示新配置。 |
| capability | 表示新的設(shè)備能力。 |
Since:
3
createPattern
public abstract Pattern createPattern(ListTypedAttribute.AttrData data)
基于包含 TypedAttribute.AttrData 的數(shù)組創(chuàng)建 Pattern 實例。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| data | 表示屬性數(shù)據(jù)的集合。 每個屬性數(shù)據(jù)都有自己的名稱、值和類型。 |
返回:
返回創(chuàng)建的 Pattern 實例。
Since:
4
createTheme
public abstract Theme createTheme(ListTypedAttribute.AttrData data)
基于包含 TypedAttribute.AttrData 的數(shù)組創(chuàng)建一個 Theme 實例。
參數(shù):
| 參數(shù)名稱 | 參數(shù)描述 |
|---|---|
| data | 表示屬性數(shù)據(jù)的集合。 每個屬性數(shù)據(jù)都有自己的名稱、值和類型。 |
返回:
返回創(chuàng)建的 Theme 實例。
Since:
4
新聞名稱:創(chuàng)新互聯(lián)鴻蒙OS教程:鴻蒙OSResourceManager
轉(zhuǎn)載來源:http://fisionsoft.com.cn/article/djdopgg.html


咨詢
建站咨詢
