public class

HtcResources

extends Object
java.lang.Object
   ↳ com.htc.res.HtcResources

Class Overview

A convinient class for access HTC common resources.

Normally Android application is not able to access the resources defined in another package directly.

Android common resources are put inside apps/common/ and will be built to system/framework/framework-res.apk, but Resources (actually libs/utils/AssetManager.cpp:AssetManager::addDefaultAssets()) implictly includes all resources defined there to give applications direct access to them. This can be done because the IDs of common resources are reserved by Android and won't collide with resource IDs defined by applications.

On the other hand, HTC common resources are put in apps/HtcCommonRes/ and will be packed to system/framework/com.htc.resources.apk. Although it's also possible to support direct access to these resources (like Android common resources do), that would require modifying (native) AssetManager class.

Summary

Public Methods
static Context getContext(Context context)
Returns the context representing the package of HTC common resource.
static String getCurrentThemePackage(Context context)
static int getId(Context context, String resName)
Looks up an id by name in Htc framework (com.htc.R.id)
static int getLayoutId(Context context, String resName)
Looks up a layout by name in Htc framework
static Resources getResources(Context context)
Retrieves the HTC common resources.
static int getThemeStyleDrawableId(Context context, String resName)
Looks up a drawable resource Id by name in the theme package.
static View inflateLayout(Context context, int layout)
Inflates a layout in HTC common resource package.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Context getContext (Context context)

Since: API Level 2.0

Returns the context representing the package of HTC common resource.

Users can use the returned context to load resources inside the HTC common resource package.

Parameters
context The calling context.
Returns
  • Context of HTC common resources package.

public static String getCurrentThemePackage (Context context)

Since: API Level 2.0

public static int getId (Context context, String resName)

Since: API Level 2.0

Looks up an id by name in Htc framework (com.htc.R.id)

public static int getLayoutId (Context context, String resName)

Since: API Level 2.0

Looks up a layout by name in Htc framework

public static Resources getResources (Context context)

Since: API Level 2.0

Retrieves the HTC common resources.

Parameters
context The calling context.
Throws
PackageManager.NameNotFoundException if the resource package is not installed properly.

public static int getThemeStyleDrawableId (Context context, String resName)

Since: API Level 2.0

Looks up a drawable resource Id by name in the theme package.

public static View inflateLayout (Context context, int layout)

Since: API Level 2.0

Inflates a layout in HTC common resource package.

Parameters
context The calling context.
layout Which layout to inflate.
Returns
  • The root view of inflated layout.