2012-03-13 7 views
1

getText(int resId)メソッドの実装が必要です。このメソッドは、抽象クラスContext.javaでfinalと定義されており、実装はContextWrapper.javaContextThemeWrapper.javaで検索しましたが、実装が見つかりませんでした。誰かがこのメソッドの実装にリンクを投稿できますか? netmite.comでクラスの実装を調べました。ありがとうandroid getText(int resId)実装

+0

AssetManager.java Context.javaでメソッドが 'final'の場合、その実装はContext.javaになければなりません –

答えて

3

getText()の実装はContext.javaです。クラスは抽象クラスですが、このメソッドの実装があります。 Resources.getText()

public final CharSequence getText(int resId) { 
    return getResources().getText(resId); 
} 

実装:AssetManager.getResourceText()

public CharSequence getText(int id) throws NotFoundException { 
    CharSequence res = mAssets.getResourceText(id); 
    if (res != null) { 
     return res; 
    } 
    throw new NotFoundException("String resource ID #0x" 
           + Integer.toHexString(id)); 
} 

実装:

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; 
} 

UPD: @zapl loadResourceValue()により述べたようにネイティブであり、android_util_AssetManager.cppに見出すことができます。

0

ICS - フレームワーク/ベース/コア/ジャワ/アンドロイド/コンテンツ/ RES/

/** 
* 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()ネイティブおよびフレームワーク/ベース/コア/ JNIで定義されている/ android_util_AssetManager.cpp