android getText(intresid)实现
我需要查看android getText(intresid)实现,android,methods,implementation,Android,Methods,Implementation,我需要查看getText(intresid)方法的实现。这个方法在抽象类Context.java中定义为final,我在ContextWrapper.java和ContextThemeWrapper.java中搜索了实现,但我找不到任何实现。有人能给这个方法实现贴一个标签吗?我在netmite.com上查看了类的实现。谢谢这是中的getText()的实现。类是抽象的,但它具有此方法的实现 public final CharSequence getText(int resId) { ret
getText(intresid)
方法的实现。这个方法在抽象类Context.java
中定义为final,我在ContextWrapper.java
和ContextThemeWrapper.java
中搜索了实现,但我找不到任何实现。有人能给这个方法实现贴一个标签吗?我在netmite.com上查看了类的实现。谢谢这是中的getText()
的实现。类是抽象的,但它具有此方法的实现
public final CharSequence getText(int resId) {
return getResources().getText(resId);
}
执行:
执行:
Upd:如@zapl
loadResourceValue()所述,
是本机的,可以在中找到。ICS-frameworks/base/core/java/android/content/res/AssetManager.java
/**
* Retrieve the string value associated with a particular resource
* identifier for the current configuration / skin.
*/
/*package*/ final CharSequence getResourceText(int ident) {
synchronized (this) {
TypedValue tmpValue = mValue;
int block = loadResourceValue(ident, (short) 0, tmpValue, true);
if (block >= 0) {
if (tmpValue.type == TypedValue.TYPE_STRING) {
return mStringBlocks[block].get(tmpValue.data);
}
return tmpValue.coerceToString();
}
}
return null;
}
loadResourceValue()
是本机的,在frameworks/base/core/jni/android\u util\u AssetManager.cpp中定义,如果方法在Context.java中是final
,那么它的实现必须在Context.java中
final CharSequence getResourceText(int ident) {
synchronized (this) {
TypedValue tmpValue = mValue;
int block = loadResourceValue(ident, (short) 0, tmpValue, true);
if (block >= 0) {
if (tmpValue.type == TypedValue.TYPE_STRING) {
return mStringBlocks[block].get(tmpValue.data);
}
return tmpValue.coerceToString();
}
}
return null;
}
/**
* Retrieve the string value associated with a particular resource
* identifier for the current configuration / skin.
*/
/*package*/ final CharSequence getResourceText(int ident) {
synchronized (this) {
TypedValue tmpValue = mValue;
int block = loadResourceValue(ident, (short) 0, tmpValue, true);
if (block >= 0) {
if (tmpValue.type == TypedValue.TYPE_STRING) {
return mStringBlocks[block].get(tmpValue.data);
}
return tmpValue.coerceToString();
}
}
return null;
}