2013年5月24日 星期五

Android Resource

How get Resource

1. getResources().getString(android.R.string.cancel);
2. Resources.getSystem().getString(android.R.string.cancel);
3. getString(android.R.string.cancel);

The first and the third ones are using "context." invisibly. So, very often (in static members or out of activity members) you can't use them directly, unless you pass context or resource as a static variable or as a parameter into your scope. But the second one

Resources.getSystem().getString(android.R.string.cancel)
You can use ABSOLUTELY EVERYWHERE in your application, even in static constants declaration! But for system resources only


GetLocals


Resources.getSystem().getassets().getLocals()
getAsset() 是從下列路徑取得,不是從frameowrks-res.apk中取得
framework/base/core/java/android/content/res/AssetManager.java
framework/base/core/jni/android_util_AssetManager.cpp
framework/base/include/utils/AssetManager.h
framework/base/libs/utils/AssetManager.cpp
framework/base/libs/utils/ResourceTypes.cpp